[pypy-commit] pypy default: Fix for issue1111: wrap_objobjargproc() returns None in CPython.

arigo noreply at buildbot.pypy.org
Mon Apr 2 10:34:10 CEST 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r54143:7da597d3c86d
Date: 2012-04-02 10:33 +0200
http://bitbucket.org/pypy/pypy/changeset/7da597d3c86d/

Log:	Fix for issue1111: wrap_objobjargproc() returns None in CPython.

diff --git a/pypy/module/cpyext/slotdefs.py b/pypy/module/cpyext/slotdefs.py
--- a/pypy/module/cpyext/slotdefs.py
+++ b/pypy/module/cpyext/slotdefs.py
@@ -183,7 +183,7 @@
     res = generic_cpy_call(space, func_target, w_self, w_key, w_value)
     if rffi.cast(lltype.Signed, res) == -1:
         space.fromcache(State).check_and_raise_exception(always=True)
-    return space.wrap(res)
+    return space.w_None
 
 def wrap_delitem(space, w_self, w_args, func):
     func_target = rffi.cast(objobjargproc, func)
diff --git a/pypy/module/cpyext/test/test_typeobject.py b/pypy/module/cpyext/test/test_typeobject.py
--- a/pypy/module/cpyext/test/test_typeobject.py
+++ b/pypy/module/cpyext/test/test_typeobject.py
@@ -415,8 +415,11 @@
             static int
             mp_ass_subscript(PyObject *self, PyObject *key, PyObject *value)
             {
-                PyErr_SetNone(PyExc_ZeroDivisionError);
-                return -1;
+                if (PyInt_Check(key)) {
+                    PyErr_SetNone(PyExc_ZeroDivisionError);
+                    return -1;
+                }
+                return 0;
             }
             PyMappingMethods tp_as_mapping;
             static PyTypeObject Foo_Type = {
@@ -426,6 +429,8 @@
             ''')
         obj = module.new_obj()
         raises(ZeroDivisionError, obj.__setitem__, 5, None)
+        res = obj.__setitem__('foo', None)
+        assert res is None
 
     def test_tp_iter(self):
         module = self.import_extension('foo', [


More information about the pypy-commit mailing list