bpo-39890: Don't mutate the AST when compiling starred assignments (GH-18833)
This commit is contained in:
parent
4663f66f35
commit
d5aa2e941c
@ -3765,7 +3765,6 @@ assignment_helper(struct compiler *c, asdl_seq *elts)
|
|||||||
"star-unpacking assignment");
|
"star-unpacking assignment");
|
||||||
ADDOP_I(c, UNPACK_EX, (i + ((n-i-1) << 8)));
|
ADDOP_I(c, UNPACK_EX, (i + ((n-i-1) << 8)));
|
||||||
seen_star = 1;
|
seen_star = 1;
|
||||||
asdl_seq_SET(elts, i, elt->v.Starred.value);
|
|
||||||
}
|
}
|
||||||
else if (elt->kind == Starred_kind) {
|
else if (elt->kind == Starred_kind) {
|
||||||
return compiler_error(c,
|
return compiler_error(c,
|
||||||
@ -3775,7 +3774,10 @@ assignment_helper(struct compiler *c, asdl_seq *elts)
|
|||||||
if (!seen_star) {
|
if (!seen_star) {
|
||||||
ADDOP_I(c, UNPACK_SEQUENCE, n);
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user