summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_grammar.py
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2006-09-05 03:53:08 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2006-09-05 03:53:08 (GMT)
commitdac090d3e62cadd24fc6b73ab177bf98326c1849 (patch)
tree4b6fa9d21592bdd09ad8204daec1a4bf18c710de /Lib/test/test_grammar.py
parent4bc2c0919b2ed31851e9c3423ab85614fe35a75a (diff)
downloadcpython-dac090d3e62cadd24fc6b73ab177bf98326c1849.zip
cpython-dac090d3e62cadd24fc6b73ab177bf98326c1849.tar.gz
cpython-dac090d3e62cadd24fc6b73ab177bf98326c1849.tar.bz2
Bug #1520864 (again): unpacking singleton tuples in list comprehensions and
generator expressions (x for x, in ... ) works again. Sigh, I only fixed for loops the first time, not list comps and genexprs too. I couldn't find any more unpacking cases where there is a similar bug lurking. This code should be refactored to eliminate the duplication. I'm sure the listcomp/genexpr code can be refactored. I'm not sure if the for loop can re-use any of the same code though. Will backport to 2.5 (the only place it matters).
Diffstat (limited to 'Lib/test/test_grammar.py')
-rw-r--r--Lib/test/test_grammar.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index f160867..c39e416 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -825,6 +825,10 @@ verify([(i,j) for i in range(10) for j in range(5)] == list(g))
verify([ x for x in range(10) if x % 2 if x % 3 ], [1, 5, 7])
verify((x for x in range(10) if x % 2 if x % 3), [1, 5, 7])
+# Verify unpacking single element tuples in listcomp/genexp.
+vereq([x for x, in [(4,), (5,), (6,)]], [4, 5, 6])
+vereq(list(x for x, in [(7,), (8,), (9,)]), [7, 8, 9])
+
# Test ifelse expressions in various cases
def _checkeval(msg, ret):
"helper to check that evaluation of expressions is done correctly"