summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-08-15 22:59:21 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-08-15 22:59:21 (GMT)
commitc0ba828857fa1a4f726a113c811badb5f2259bb9 (patch)
treef241d1c2987545ee7db7e850b63cd60341f81f02 /Lib
parent8cabfa352b93e7126d5147a2f8f056cad8d724f6 (diff)
downloadcpython-c0ba828857fa1a4f726a113c811badb5f2259bb9.zip
cpython-c0ba828857fa1a4f726a113c811badb5f2259bb9.tar.gz
cpython-c0ba828857fa1a4f726a113c811badb5f2259bb9.tar.bz2
better col_offsets for "for" statements with tuple unpacking #6704
Patch from Frank Wierzbicki.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_ast.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py
index 6dca5d2..14e31bd 100644
--- a/Lib/test/test_ast.py
+++ b/Lib/test/test_ast.py
@@ -64,6 +64,10 @@ exec_tests = [
"break",
# Continue
"continue",
+ # for statements with naked tuples (see http://bugs.python.org/issue6704)
+ "for a,b in c: pass",
+ "[(a,b) for a,b in c]",
+ "((a,b) for a,b in c)",
]
# These are compiled through "single"
@@ -301,7 +305,7 @@ def main():
print kind+"_results = ["
for s in statements:
print repr(to_tuple(compile(s, "?", kind, 0x400)))+","
- print "]"
+ print "]"
print "main()"
raise SystemExit
test_main()
@@ -330,6 +334,9 @@ exec_results = [
('Module', [('Pass', (1, 0))]),
('Module', [('Break', (1, 0))]),
('Module', [('Continue', (1, 0))]),
+('Module', [('For', (1, 0), ('Tuple', (1, 4), [('Name', (1, 4), 'a', ('Store',)), ('Name', (1, 6), 'b', ('Store',))], ('Store',)), ('Name', (1, 11), 'c', ('Load',)), [('Pass', (1, 14))], [])]),
+('Module', [('Expr', (1, 0), ('ListComp', (1, 1), ('Tuple', (1, 2), [('Name', (1, 2), 'a', ('Load',)), ('Name', (1, 4), 'b', ('Load',))], ('Load',)), [('comprehension', ('Tuple', (1, 11), [('Name', (1, 11), 'a', ('Store',)), ('Name', (1, 13), 'b', ('Store',))], ('Store',)), ('Name', (1, 18), 'c', ('Load',)), [])]))]),
+('Module', [('Expr', (1, 0), ('GeneratorExp', (1, 1), ('Tuple', (1, 2), [('Name', (1, 2), 'a', ('Load',)), ('Name', (1, 4), 'b', ('Load',))], ('Load',)), [('comprehension', ('Tuple', (1, 11), [('Name', (1, 11), 'a', ('Store',)), ('Name', (1, 13), 'b', ('Store',))], ('Store',)), ('Name', (1, 18), 'c', ('Load',)), [])]))]),
]
single_results = [
('Interactive', [('Expr', (1, 0), ('BinOp', (1, 0), ('Num', (1, 0), 1), ('Add',), ('Num', (1, 2), 2)))]),