summaryrefslogtreecommitdiffstats
path: root/Python/compile.c
diff options
context:
space:
mode:
authorMark Dickinson <mdickinson@enthought.com>2012-11-25 14:36:26 (GMT)
committerMark Dickinson <mdickinson@enthought.com>2012-11-25 14:36:26 (GMT)
commitded35aeb9d5ae1671174f10c0ae8a7166693b17c (patch)
tree4caa61589581de32b38d3da8ee8bd68e553094bf /Python/compile.c
parent9982c53c2feb6e6e03c4c6d87d77c6ee69bfc435 (diff)
downloadcpython-ded35aeb9d5ae1671174f10c0ae8a7166693b17c.zip
cpython-ded35aeb9d5ae1671174f10c0ae8a7166693b17c.tar.gz
cpython-ded35aeb9d5ae1671174f10c0ae8a7166693b17c.tar.bz2
Issue #16546: make ast.YieldFrom argument mandatory.
Diffstat (limited to 'Python/compile.c')
-rw-r--r--Python/compile.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/Python/compile.c b/Python/compile.c
index 5016f99..3cf71ef 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -3341,27 +3341,24 @@ compiler_visit_expr(struct compiler *c, expr_ty e)
case DictComp_kind:
return compiler_dictcomp(c, e);
case Yield_kind:
- case YieldFrom_kind: {
- expr_ty value;
if (c->u->u_ste->ste_type != FunctionBlock)
return compiler_error(c, "'yield' outside function");
- value = (e->kind == YieldFrom_kind) ? e->v.YieldFrom.value : e->v.Yield.value;
- if (value) {
- VISIT(c, expr, value);
+ if (e->v.Yield.value) {
+ VISIT(c, expr, e->v.Yield.value);
}
else {
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 {
- ADDOP(c, YIELD_VALUE);
- }
+ ADDOP(c, YIELD_VALUE);
+ break;
+ case YieldFrom_kind:
+ if (c->u->u_ste->ste_type != FunctionBlock)
+ return compiler_error(c, "'yield' outside function");
+ VISIT(c, expr, e->v.YieldFrom.value);
+ ADDOP(c, GET_ITER);
+ ADDOP_O(c, LOAD_CONST, Py_None, consts);
+ ADDOP(c, YIELD_FROM);
break;
- }
case Compare_kind:
return compiler_compare(c, e);
case Call_kind: