diff Python/ceval.c @ 74364:315781cd72fa

NULL and no exception set from tp_iternext means StopIteration
author Benjamin Peterson <benjamin@python.org>
date Fri, 13 Jan 2012 14:54:31 -0500
parents d64ac9ab4cd0
children fbb38a476713
line wrap: on
line diff
--- a/Python/ceval.c	Fri Jan 13 14:39:38 2012 -0500
+++ b/Python/ceval.c	Fri Jan 13 14:54:31 2012 -0500
@@ -1839,7 +1839,8 @@
             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;
                 }