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

afa at codespeak.net afa at codespeak.net
Tue Apr 20 23:46:38 CEST 2010


Author: afa
Date: Tue Apr 20 23:46:36 2010
New Revision: 73921

Modified:
   pypy/branch/cpython-extension/pypy/module/cpyext/slotdefs.py
   pypy/branch/cpython-extension/pypy/module/cpyext/state.py
Log:
The slots setitem and delitem don't return a real value, only an error indicator.
This should fix translation.


Modified: pypy/branch/cpython-extension/pypy/module/cpyext/slotdefs.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/slotdefs.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/slotdefs.py	Tue Apr 20 23:46:36 2010
@@ -67,7 +67,8 @@
     check_num_args(space, w_args, 2)
     args_w = space.fixedview(w_args)
     index = space.int_w(space.index(args_w[0]))
-    return generic_cpy_call(space, func_target, w_self, index, args_w[1])
+    if generic_cpy_call(space, func_target, w_self, index, args_w[1]) == -1:
+        space.fromcache(State).check_and_raise_exception()
 
 def wrap_sq_delitem(space, w_self, w_args, func):
     func_target = rffi.cast(ssizeobjargproc, func)
@@ -75,7 +76,8 @@
     args_w = space.fixedview(w_args)
     index = space.int_w(space.index(args_w[0]))
     null = lltype.nullptr(PyObject.TO)
-    return generic_cpy_call(space, func_target, w_self, index, null)
+    if generic_cpy_call(space, func_target, w_self, index, null) == -1:
+        space.fromcache(State).check_and_raise_exception(always=True)
 
 def wrap_ssizessizeargfunc(space, w_self, w_args, func):
     func_target = rffi.cast(ssizessizeargfunc, func)

Modified: pypy/branch/cpython-extension/pypy/module/cpyext/state.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/state.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/state.py	Tue Apr 20 23:46:36 2010
@@ -51,13 +51,16 @@
         self.exc_type = None
         self.exc_value = None
 
-    def check_and_raise_exception(self):
+    def check_and_raise_exception(self, always=False):
         exc_value = self.exc_value
         exc_type = self.exc_type
         if exc_type is not None or exc_value is not None:
             self.clear_exception()
             op_err = OperationError(exc_type, exc_value)
             raise op_err
+        if always:
+            raise OperationError(space.w_SystemError, space.wrap(
+                "Function returned an error result without setting an exception"))
 
     def print_refcounts(self):
         print "REFCOUNTS"



More information about the Pypy-commit mailing list