diff options
author | Guido van Rossum <guido@python.org> | 2020-05-14 19:01:14 -0700 |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2020-05-14 19:01:14 -0700 |
commit | f93a54c48fc1644012aa0d4ee3887c1d121ac40e (patch) | |
tree | 189c841245d15318e5895638105bdbc532cbcdf5 /Python/ast.c | |
parent | 31641ff0e4b18c8d002d019f4506f0e8fb446983 (diff) | |
parent | 16ab07063cb564c1937714bd39d6915172f005b5 (diff) | |
download | cpython-git-fix-traceback-syntax-error.tar.gz |
Merge branch 'master' into fix-traceback-syntax-errorfix-traceback-syntax-error
Diffstat (limited to 'Python/ast.c')
-rw-r--r-- | Python/ast.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Python/ast.c b/Python/ast.c index 1a4a3110e6..2d20ca62aa 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -3164,10 +3164,7 @@ ast_for_expr_stmt(struct compiling *c, const node *n) expr1 = ast_for_testlist(c, ch); if (!expr1) return NULL; - if(!set_context(c, expr1, Store, ch)) - return NULL; - /* set_context checks that most expressions are not the left side. - Augmented assignments can only have a name, a subscript, or an + /* Augmented assignments can only have a name, a subscript, or an attribute on the left, though, so we have to explicitly check for those. */ switch (expr1->kind) { @@ -3176,10 +3173,16 @@ ast_for_expr_stmt(struct compiling *c, const node *n) case Subscript_kind: break; default: - ast_error(c, ch, "illegal expression for augmented assignment"); + ast_error(c, ch, "'%s' is an illegal expression for augmented assignment", + get_expr_name(expr1)); return NULL; } + /* set_context checks that most expressions are not the left side. */ + if(!set_context(c, expr1, Store, ch)) { + return NULL; + } + ch = CHILD(n, 2); if (TYPE(ch) == testlist) expr2 = ast_for_testlist(c, ch); |