summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2012-03-15 20:37:39 (GMT)
committerBenjamin Peterson <benjamin@python.org>2012-03-15 20:37:39 (GMT)
commit2afe6aeae820cf2272c6f9be60b185e1c27b734b (patch)
tree806b2e778fa2d90648e9eca16f306769bd804d16 /Python/compile.c
parent3270d11d8aee447e6cbd5388d677b4a23879e80e (diff)
downloadcpython-2afe6aeae820cf2272c6f9be60b185e1c27b734b.zip
cpython-2afe6aeae820cf2272c6f9be60b185e1c27b734b.tar.gz
cpython-2afe6aeae820cf2272c6f9be60b185e1c27b734b.tar.bz2
perform yield from delegation by repeating YIELD_FROM opcode (closes #14230)
This allows generators that are using yield from to be seen by debuggers. It also kills the f_yieldfrom field on frame objects. Patch mostly from Mark Shannon with a few tweaks by me.
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Python/compile.c b/Python/compile.c
index b64c800..1722a5f 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -840,9 +840,9 @@ opcode_stack_effect(int opcode, int oparg)
case IMPORT_STAR:
return -1;
case YIELD_VALUE:
- case YIELD_FROM:
return 0;
-
+ case YIELD_FROM:
+ return -1;
case POP_BLOCK:
return 0;
case POP_EXCEPT:
@@ -3323,6 +3323,8 @@ compiler_visit_expr(struct compiler *c, expr_ty e)
ADDOP_O(c, LOAD_CONST, Py_None, consts);
}
if (e->kind == YieldFrom_kind) {
+ ADDOP(c, GET_ITER);
+ ADDOP_O(c, LOAD_CONST, Py_None, consts);
ADDOP(c, YIELD_FROM);
}
else {