[Python-checkins] cpython: NULL and no exception set from tp_iternext means StopIteration
benjamin.peterson
python-checkins at python.org
Fri Jan 13 20:54:37 CET 2012
http://hg.python.org/cpython/rev/315781cd72fa
changeset: 74364:315781cd72fa
user: Benjamin Peterson <benjamin at python.org>
date: Fri Jan 13 14:54:31 2012 -0500
summary:
NULL and no exception set from tp_iternext means StopIteration
files:
Lib/test/test_pep380.py | 5 +++++
Python/ceval.c | 3 ++-
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/Lib/test/test_pep380.py b/Lib/test/test_pep380.py
--- a/Lib/test/test_pep380.py
+++ b/Lib/test/test_pep380.py
@@ -831,6 +831,11 @@
"Enter f",
])
+ def test_yield_from_empty(self):
+ def g():
+ yield from ()
+ self.assertRaises(StopIteration, next, g())
+
def test_main():
from test import support
diff --git a/Python/ceval.c b/Python/ceval.c
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -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;
}
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list