[pypy-svn] pypy psycopg2compatibility: Fixed translation.

ademan commits-noreply at bitbucket.org
Wed Dec 22 08:04:04 CET 2010


Author: Daniel Roberts <Ademan555 at gmail.com>
Branch: psycopg2compatibility
Changeset: r40172:7668e3180d63
Date: 2010-12-21 22:24 -0800
http://bitbucket.org/pypy/pypy/changeset/7668e3180d63/

Log:	Fixed translation.

diff --git a/pypy/module/cpyext/pyobject.py b/pypy/module/cpyext/pyobject.py
--- a/pypy/module/cpyext/pyobject.py
+++ b/pypy/module/cpyext/pyobject.py
@@ -289,7 +289,7 @@
     # XXX looks like a PyObject_GC_TRACK
     ptr = rffi.cast(ADDR, py_obj)
     state = space.fromcache(RefcountState)
-    if DEBUG_REFCOUNT:
+    if DEBUG_REFCOUNT and not we_are_translated():
         debug_refcount("MAKREF", py_obj, w_obj)
         if not replace:
             if not we_are_translated():
@@ -354,7 +354,7 @@
     assert lltype.typeOf(obj) == PyObject
 
     obj.c_ob_refcnt -= 1
-    if DEBUG_REFCOUNT:
+    if DEBUG_REFCOUNT and not we_are_translated():
         debug_refcount("DECREF", obj, obj.c_ob_refcnt)
     if obj.c_ob_refcnt == 0:
         state = space.fromcache(RefcountState)
@@ -387,7 +387,7 @@
         return
     obj.c_ob_refcnt += 1
     assert obj.c_ob_refcnt > 0
-    if DEBUG_REFCOUNT:
+    if DEBUG_REFCOUNT and not we_are_translated():
         debug_refcount("INCREF", obj, obj.c_ob_refcnt)
 
 @cpython_api([PyObject], lltype.Void)

diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -629,6 +629,7 @@
                     result = callable(space, *boxed_args)
             except OperationError, e:
                 failed = True
+                message = str(e)
                 state.set_exception(e)
             except BaseException, e:
                 failed = True
@@ -646,12 +647,12 @@
             if failed:
                 error_value = callable.api_func.error_value
                 if error_value is CANNOT_FAIL:
-                    if not we_are_translated():
-                        raise SystemError("The function '%s' was not supposed to fail.  Failed with %s"
-                                          % (function_name, e))
-                    else:
+                    if we_are_translated():
                         raise SystemError("The function '%s' was not supposed to fail"
                                           % (function_name,))
+                    else:
+                        raise SystemError("The function '%s' was not supposed to fail.  Failed with '%s'"
+                                          % (function_name, message))
                 retval = error_value
 
             elif is_PyObject(callable.api_func.restype):


More information about the Pypy-commit mailing list