diff options
-rw-r--r-- | Lib/test/test_generators.py | 20 | ||||
-rw-r--r-- | Misc/NEWS | 3 | ||||
-rw-r--r-- | Python/ceval.c | 4 |
3 files changed, 25 insertions, 2 deletions
diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py index 77c477f..17523ba 100644 --- a/Lib/test/test_generators.py +++ b/Lib/test/test_generators.py @@ -805,6 +805,26 @@ SyntaxError: invalid syntax ... yield 2 # because it's a generator Traceback (most recent call last): SyntaxError: 'return' with argument inside generator (<string>, line 8) + +This one caused a crash (see SF bug 567538): + +>>> def f(): +... for i in range(3): +... try: +... continue +... finally: +... yield i +... +>>> g = f() +>>> print g.next() +0 +>>> print g.next() +1 +>>> print g.next() +2 +>>> print g.next() +Traceback (most recent call last): +StopIteration """ # conjoin is a simple backtracking generator, named in honor of Icon's @@ -6,6 +6,9 @@ Type/class unification and new-style classes Core and builtins +- Fixed a bug with a continue inside a try block and a yield in the + finally clause. [SF bug 567538] + - Most builtin sequences now support "extended slices", i.e. slices with a third "stride" parameter. For example, "range(10)[1:6:2]" evaluates to [1, 3, 5]. diff --git a/Python/ceval.c b/Python/ceval.c index fd30e8f..b9c0d5d 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1543,7 +1543,7 @@ eval_frame(PyFrameObject *f) why = (enum why_code) PyInt_AsLong(v); if (why == WHY_RETURN || why == WHY_YIELD || - why == CONTINUE_LOOP) + why == WHY_CONTINUE) retval = POP(); } else if (PyString_Check(v) || PyClass_Check(v)) { @@ -2293,7 +2293,7 @@ eval_frame(PyFrameObject *f) } else { if (why == WHY_RETURN || - why == CONTINUE_LOOP) + why == WHY_CONTINUE) PUSH(retval); v = PyInt_FromLong((long)why); PUSH(v); |