summaryrefslogtreecommitdiffstats
path: root/Python/ast.c
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2006-07-12 05:26:17 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2006-07-12 05:26:17 (GMT)
commitedef2be4af973f1766b593cf48188db2e320dcbe (patch)
tree3daf8d96b916450d9f214851e0194c41c2243a42 /Python/ast.c
parent3b9be2ae6f5491737ebc65ee525884da218368d4 (diff)
downloadcpython-edef2be4af973f1766b593cf48188db2e320dcbe.zip
cpython-edef2be4af973f1766b593cf48188db2e320dcbe.tar.gz
cpython-edef2be4af973f1766b593cf48188db2e320dcbe.tar.bz2
Bug #1520864: unpacking singleton tuples in for loop (for x, in) work again.
Diffstat (limited to 'Python/ast.c')
-rw-r--r--Python/ast.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/Python/ast.c b/Python/ast.c
index cd0649e..d00fcc8 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -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);