summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2011-07-03 18:48:36 (GMT)
committerBenjamin Peterson <benjamin@python.org>2011-07-03 18:48:36 (GMT)
commit7b7099c36f30f1aca77f0ce285e3b68c4f23455e (patch)
treebe4dfbb76d613124e8d0feaf92a433828b3811bc /Python
parent92843e3c144b3a7a78e1c6b11ec85f06227c42ab (diff)
parentd2ed63024312630d11b0800d985f8b1fa96711a3 (diff)
downloadcpython-7b7099c36f30f1aca77f0ce285e3b68c4f23455e.zip
cpython-7b7099c36f30f1aca77f0ce285e3b68c4f23455e.tar.gz
cpython-7b7099c36f30f1aca77f0ce285e3b68c4f23455e.tar.bz2
merge 3.2 (#12475)
Diffstat (limited to 'Python')
-rw-r--r--Python/ceval.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 33213fa..4f7ba80 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -1865,10 +1865,6 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
retval = POP();
f->f_stacktop = stack_pointer;
why = WHY_YIELD;
- /* Put aside the current exception state and restore
- that of the calling frame. This only serves when
- "yield" is used inside an except handler. */
- SWAP_EXC_STATE();
goto fast_yield;
TARGET(POP_EXCEPT)
@@ -3005,6 +3001,11 @@ fast_block_end:
retval = NULL;
fast_yield:
+ if (co->co_flags & CO_GENERATOR && (why == WHY_YIELD || why == WHY_RETURN))
+ /* Put aside the current exception state and restore that of the
+ calling frame. */
+ SWAP_EXC_STATE();
+
if (tstate->use_tracing) {
if (tstate->c_tracefunc) {
if (why == WHY_RETURN || why == WHY_YIELD) {