[pypy-svn] pypy default: Push and pull until "with traits.scoped_alloc_buffer()" is allowed in a ll helper.
amauryfa
commits-noreply at bitbucket.org
Fri Jan 21 19:11:39 CET 2011
Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch:
Changeset: r41175:0621c4883cce
Date: 2011-01-21 19:03 +0100
http://bitbucket.org/pypy/pypy/changeset/0621c4883cce/
Log: Push and pull until "with traits.scoped_alloc_buffer()" is allowed
in a ll helper. This fixes the translation on Windows
diff --git a/pypy/rpython/module/ll_win32file.py b/pypy/rpython/module/ll_win32file.py
--- a/pypy/rpython/module/ll_win32file.py
+++ b/pypy/rpython/module/ll_win32file.py
@@ -260,19 +260,25 @@
"""
if not win32traits.SetCurrentDirectory(path):
raise rwin32.lastWindowsError()
+ MAX_PATH = rwin32.MAX_PATH
+ assert MAX_PATH > 0
- with traits.scoped_alloc_buffer(rwin32.MAX_PATH) as path:
- res = win32traits.GetCurrentDirectory(rwin32.MAX_PATH + 1, path.raw)
+ with traits.scoped_alloc_buffer(MAX_PATH) as path:
+ res = win32traits.GetCurrentDirectory(MAX_PATH + 1, path.raw)
if not res:
raise rwin32.lastWindowsError()
- if res <= rwin32.MAX_PATH + 1:
- new_path = path.str(rffi.cast(lltype.Signed, res))
+ res = rffi.cast(lltype.Signed, res)
+ assert res > 0
+ if res <= MAX_PATH + 1:
+ new_path = path.str(res)
else:
- with traits.scoped_alloc_buffer(rwin32.MAX_PATH) as path:
+ with traits.scoped_alloc_buffer(res) as path:
res = win32traits.GetCurrentDirectory(res, path.raw)
if not res:
raise rwin32.lastWindowsError()
- new_path = path.str(rffi.cast(lltype.Signed, res))
+ res = rffi.cast(lltype.Signed, res)
+ assert res > 0
+ new_path = path.str(res)
if isUNC(new_path):
return
if not win32traits.SetEnvironmentVariable(magic_envvar(new_path), new_path):
diff --git a/pypy/objspace/flow/flowcontext.py b/pypy/objspace/flow/flowcontext.py
--- a/pypy/objspace/flow/flowcontext.py
+++ b/pypy/objspace/flow/flowcontext.py
@@ -444,7 +444,7 @@
# The annotator won't allow to merge exception types with None.
# Replace it with an object which will break translation when used
# (except maybe with 'exc_typ is None')
- w_typ = self.space.wrap(self.space)
+ w_typ = self.space.w_None
self.space.call_function(w_func, w_typ, w_val, w_tb)
# Return None so that the flow space statically knows that we didn't
# swallow the exception
More information about the Pypy-commit
mailing list