diff options
author | Guido van Rossum <guido@python.org> | 2018-07-16 09:45:49 -0700 |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2018-07-16 09:45:49 -0700 |
commit | 4058b938da4b649fb91a2f4a3c9fb041b30fbaa8 (patch) | |
tree | 16bc17dbbec5ac0b8149e5667dd450c6ec525d0d | |
parent | dfb6c217ab8c9e024f02b30a7f412b7b9214fcae (diff) | |
download | cpython-git-4058b938da4b649fb91a2f4a3c9fb041b30fbaa8.tar.gz |
Actually generate code to assign to target
(But it always is a global somehow.)
-rw-r--r-- | Python/ast.c | 15 | ||||
-rw-r--r-- | Python/compile.c | 2 |
2 files changed, 11 insertions, 6 deletions
diff --git a/Python/ast.c b/Python/ast.c index 38b75cbe3a..3072cb68d1 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -1693,17 +1693,20 @@ ast_for_decorated(struct compiling *c, const node *n) static expr_ty ast_for_ass_expr(struct compiling *c, const node *n) { - expr_ty expr1, expr2; + expr_ty target, value; - expr1 = ast_for_expr(c, CHILD(n, 0)); - if (!expr1) + target = ast_for_expr(c, CHILD(n, 0)); + if (!target) return NULL; - expr2 = ast_for_expr(c, CHILD(n, 2)); - if (!expr2) + value = ast_for_expr(c, CHILD(n, 2)); + if (!value) + return NULL; + + if(!set_context(c, target, Store, n)) return NULL; - return AssExpr(expr1, expr2, LINENO(n), n->n_col_offset, c->c_arena); + return AssExpr(target, value, LINENO(n), n->n_col_offset, c->c_arena); } static expr_ty diff --git a/Python/compile.c b/Python/compile.c index 26c0c6b6a6..d71b33121c 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -4444,6 +4444,8 @@ compiler_visit_expr(struct compiler *c, expr_ty e) switch (e->kind) { case AssExpr_kind: VISIT(c, expr, e->v.AssExpr.value); + ADDOP(c, DUP_TOP); + VISIT(c, expr, e->v.AssExpr.target); break; case BoolOp_kind: return compiler_boolop(c, e); |