Author: Amaury Forgeot d'Arc <amaur...@gmail.com>
Branch: 
Changeset: r54486:52c0ca3486b4
Date: 2012-04-17 22:28 +0200
http://bitbucket.org/pypy/pypy/changeset/52c0ca3486b4/

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

diff --git a/pypy/module/cpyext/iterator.py b/pypy/module/cpyext/iterator.py
--- a/pypy/module/cpyext/iterator.py
+++ b/pypy/module/cpyext/iterator.py
@@ -22,7 +22,7 @@
     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
diff --git a/pypy/module/cpyext/test/test_iterator.py 
b/pypy/module/cpyext/test/test_iterator.py
--- a/pypy/module/cpyext/test/test_iterator.py
+++ b/pypy/module/cpyext/test/test_iterator.py
@@ -15,3 +15,8 @@
         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()
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to