mirror of
https://github.com/python/cpython.git
synced 2025-07-28 13:44:43 +00:00
Bug #1520864: unpacking singleton tuples in for loop (for x, in) work again.
This commit is contained in:
parent
3b9be2ae6f
commit
edef2be4af
4 changed files with 14 additions and 2 deletions
|
@ -2666,6 +2666,7 @@ ast_for_for_stmt(struct compiling *c, const node *n)
|
|||
asdl_seq *_target, *seq = NULL, *suite_seq;
|
||||
expr_ty expression;
|
||||
expr_ty target;
|
||||
const node *node_target;
|
||||
/* for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite] */
|
||||
REQ(n, for_stmt);
|
||||
|
||||
|
@ -2675,10 +2676,13 @@ ast_for_for_stmt(struct compiling *c, const node *n)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
_target = ast_for_exprlist(c, CHILD(n, 1), Store);
|
||||
node_target = CHILD(n, 1);
|
||||
_target = ast_for_exprlist(c, node_target, Store);
|
||||
if (!_target)
|
||||
return NULL;
|
||||
if (asdl_seq_LEN(_target) == 1)
|
||||
/* Check the # of children rather than the length of _target, since
|
||||
for x, in ... has 1 element in _target, but still requires a Tuple. */
|
||||
if (NCH(node_target) == 1)
|
||||
target = (expr_ty)asdl_seq_GET(_target, 0);
|
||||
else
|
||||
target = Tuple(_target, Store, LINENO(n), n->n_col_offset, c->c_arena);
|
||||
|
|
|
@ -60,6 +60,7 @@ extern time_t PyOS_GetLastModificationTime(char *, FILE *);
|
|||
Python 2.5a0: 62081 (ast-branch)
|
||||
Python 2.5a0: 62091 (with)
|
||||
Python 2.5a0: 62092 (changed WITH_CLEANUP opcode)
|
||||
Python 2.5c1: 62101 (fix wrong code: for x, in ...)
|
||||
.
|
||||
*/
|
||||
#define MAGIC (62092 | ((long)'\r'<<16) | ((long)'\n'<<24))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue