]> granicus.if.org Git - python/commitdiff
NULL and no exception set from tp_iternext means StopIteration
authorBenjamin Peterson <benjamin@python.org>
Fri, 13 Jan 2012 19:54:31 +0000 (14:54 -0500)
committerBenjamin Peterson <benjamin@python.org>
Fri, 13 Jan 2012 19:54:31 +0000 (14:54 -0500)
Lib/test/test_pep380.py
Python/ceval.c

index 53e9735eb370bfa4e0d1b385a75b78ad634a6adc..6554b0fa5c6d0e597906479644521023a696208c 100644 (file)
@@ -831,6 +831,11 @@ class TestPEP380Operation(unittest.TestCase):
             "Enter f",
         ])
 
+    def test_yield_from_empty(self):
+        def g():
+            yield from ()
+        self.assertRaises(StopIteration, next, g())
+
 
 def test_main():
     from test import support
index 134d1eec4b7a6b3becc9b3d2a416841dd6531dd9..98219b0c9d7195e76ae904866ff4e5b7d2f2ec78 100644 (file)
@@ -1839,7 +1839,8 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
             if (!retval) {
                 /* iter may be exhausted */
                 Py_CLEAR(x);
-                if (!PyErr_ExceptionMatches(PyExc_StopIteration)) {
+                if (PyErr_Occurred() &&
+                    !PyErr_ExceptionMatches(PyExc_StopIteration)) {
                     /* some other exception */
                     break;
                 }