1. Alexander Hesse
  2. pypy

Commits

Armin Rigo  committed 7da597d

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

  • Participants
  • Parent commits 171b149
  • Branches default

Comments (0)

Files changed (2)

File pypy/module/cpyext/slotdefs.py

View file
     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)

File pypy/module/cpyext/test/test_typeobject.py

View file
             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 = {
             ''')
         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', [