[pypy-svn] r73710 - pypy/branch/cpython-extension/pypy/module/cpyext

fijal at codespeak.net fijal at codespeak.net
Tue Apr 13 05:38:35 CEST 2010


Author: fijal
Date: Tue Apr 13 05:38:33 2010
New Revision: 73710

Modified:
   pypy/branch/cpython-extension/pypy/module/cpyext/api.py
Log:
Try not to mix W_Xxx instance with PyObject pointers


Modified: pypy/branch/cpython-extension/pypy/module/cpyext/api.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/api.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/api.py	Tue Apr 13 05:38:33 2010
@@ -372,7 +372,7 @@
                 boxed_args += (arg_conv, )
             state = space.fromcache(State)
             try:
-                retval = callable(space, *boxed_args)
+                result = callable(space, *boxed_args)
                 if not we_are_translated() and DEBUG_WRAPPER:
                     print >>sys.stderr, " DONE"
             except OperationError, e:
@@ -397,12 +397,14 @@
 
             elif callable.api_func.restype is PyObject:
                 borrowed = callable.api_func.borrowed
-                if not rffi._isllptr(retval):
-                    retval = make_ref(space, retval, borrowed=borrowed)
+                if not rffi._isllptr(result):
+                    retval = make_ref(space, result, borrowed=borrowed)
+                else:
+                    retval = result
                 if borrowed:
                     add_borrowed_object(space, retval)
             elif callable.api_func.restype is not lltype.Void:
-                retval = rffi.cast(callable.api_func.restype, retval)
+                retval = rffi.cast(callable.api_func.restype, result)
         except NullPointerException, e:
             print "Container not registered by %s" % callable.__name__
         except:



More information about the Pypy-commit mailing list