summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2012-01-13 14:54:31 -0500
committerBenjamin Peterson <benjamin@python.org>2012-01-13 14:54:31 -0500
commit0296a565205651b60a3a5690432beb6f3333a7fc (patch)
treea0341f20773fab2e74c99a0b328743d29270cb3a
parent9a80fa81b0195bb744f89565bbc212d39c300942 (diff)
downloadcpython-git-0296a565205651b60a3a5690432beb6f3333a7fc.tar.gz
NULL and no exception set from tp_iternext means StopIteration
-rw-r--r--Lib/test/test_pep380.py5
-rw-r--r--Python/ceval.c3
2 files changed, 7 insertions, 1 deletions
diff --git a/Lib/test/test_pep380.py b/Lib/test/test_pep380.py
index 53e9735eb3..6554b0fa5c 100644
--- a/Lib/test/test_pep380.py
+++ b/Lib/test/test_pep380.py
@@ -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
diff --git a/Python/ceval.c b/Python/ceval.c
index 134d1eec4b..98219b0c9d 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -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;
}