diff options
author | Neil Schemenauer <nascheme@enme.ucalgary.ca> | 2006-07-09 16:16:34 (GMT) |
---|---|---|
committer | Neil Schemenauer <nascheme@enme.ucalgary.ca> | 2006-07-09 16:16:34 (GMT) |
commit | 0e07b60a4e44129cfafaeacac765cf957e2ea219 (patch) | |
tree | bf67b1a4f4302118d38e3c57ddd91f20da8b1d99 /Python | |
parent | 63597f129d73ddcfc2f3adc99d0d84d1da91082e (diff) | |
download | cpython-0e07b60a4e44129cfafaeacac765cf957e2ea219.zip cpython-0e07b60a4e44129cfafaeacac765cf957e2ea219.tar.gz cpython-0e07b60a4e44129cfafaeacac765cf957e2ea219.tar.bz2 |
Fix AST compiler bug #1501934: incorrect LOAD/STORE_GLOBAL generation.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ast.c | 5 | ||||
-rw-r--r-- | Python/compile.c | 3 |
2 files changed, 5 insertions, 3 deletions
diff --git a/Python/ast.c b/Python/ast.c index 4c78b00..6fd1ebe 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -339,7 +339,7 @@ set_context(expr_ty e, expr_context_ty ctx, const node *n) /* The ast defines augmented store and load contexts, but the implementation here doesn't actually use them. The code may be a little more complex than necessary as a result. It also means - that expressions in an augmented assignment have no context. + that expressions in an augmented assignment have a Store context. Consider restructuring so that augmented assignment uses set_context(), too. */ @@ -1901,7 +1901,7 @@ ast_for_expr_stmt(struct compiling *c, const node *n) if (!expr1) return NULL; - /* TODO(jhylton): Figure out why set_context() can't be used here. */ + /* TODO(nas): Remove duplicated error checks (set_context does it) */ switch (expr1->kind) { case GeneratorExp_kind: ast_error(ch, "augmented assignment to generator " @@ -1923,6 +1923,7 @@ ast_for_expr_stmt(struct compiling *c, const node *n) "assignment"); return NULL; } + set_context(expr1, Store, ch); ch = CHILD(n, 2); if (TYPE(ch) == testlist) diff --git a/Python/compile.c b/Python/compile.c index 5bda62e..3ddb067 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -3688,7 +3688,8 @@ compiler_augassign(struct compiler *c, stmt_ty s) VISIT(c, expr, auge); break; case Name_kind: - VISIT(c, expr, s->v.AugAssign.target); + if (!compiler_nameop(c, e->v.Name.id, Load)) + return 0; VISIT(c, expr, s->v.AugAssign.value); ADDOP(c, inplace_binop(c, s->v.AugAssign.op)); return compiler_nameop(c, e->v.Name.id, Store); |