Commits

Amaury Forgeot d'Arc  committed 52c0ca3

Fix a crash PyIter_Next() when space.next() raises an exception.

  • Participants
  • Parent commits f4cd131

Comments (0)

Files changed (2)

File pypy/module/cpyext/iterator.py

     cannot be iterated."""
     return space.iter(w_obj)
 
-@cpython_api([PyObject], PyObject, error=CANNOT_FAIL)
+@cpython_api([PyObject], PyObject)
 def PyIter_Next(space, w_obj):
     """Return the next value from the iteration o.  If the object is an
     iterator, this retrieves the next value from the iteration, and returns

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

         assert space.unwrap(api.PyIter_Next(w_iter)) == 3
         assert api.PyIter_Next(w_iter) is None
         assert not api.PyErr_Occurred()
+
+    def test_iternext_error(self,space, api):
+        assert api.PyIter_Next(space.w_None) is None
+        assert api.PyErr_Occurred() is space.w_TypeError
+        api.PyErr_Clear()