summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrandt Bucher <brandtbucher@gmail.com>2020-03-08 03:44:18 (GMT)
committerGitHub <noreply@github.com>2020-03-08 03:44:18 (GMT)
commitd5aa2e941ccc44412b95d0e3f0a1789fbcccf403 (patch)
tree45dcf3582a3be17c7a545c3d08fdb804d5690eb2
parent4663f66f3554dd8e2ec130e40f6abb3c6a514775 (diff)
downloadcpython-d5aa2e941ccc44412b95d0e3f0a1789fbcccf403.zip
cpython-d5aa2e941ccc44412b95d0e3f0a1789fbcccf403.tar.gz
cpython-d5aa2e941ccc44412b95d0e3f0a1789fbcccf403.tar.bz2
bpo-39890: Don't mutate the AST when compiling starred assignments (GH-18833)
-rw-r--r--Python/compile.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Python/compile.c b/Python/compile.c
index f603e3d..f228e16 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -3765,7 +3765,6 @@ assignment_helper(struct compiler *c, asdl_seq *elts)
"star-unpacking assignment");
ADDOP_I(c, UNPACK_EX, (i + ((n-i-1) << 8)));
seen_star = 1;
- asdl_seq_SET(elts, i, elt->v.Starred.value);
}
else if (elt->kind == Starred_kind) {
return compiler_error(c,
@@ -3775,7 +3774,10 @@ assignment_helper(struct compiler *c, asdl_seq *elts)
if (!seen_star) {
ADDOP_I(c, UNPACK_SEQUENCE, n);
}
- VISIT_SEQ(c, expr, elts);
+ for (i = 0; i < n; i++) {
+ expr_ty elt = asdl_seq_GET(elts, i);
+ VISIT(c, expr, elt->kind != Starred_kind ? elt : elt->v.Starred.value);
+ }
return 1;
}