summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2005-10-21 06:24:02 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2005-10-21 06:24:02 (GMT)
commit37c0844b35b9a4d68f7ddf3a8b38d3e013f17d78 (patch)
tree345859c3266fdc71bf64f076ed16507c2d3051de /Lib
parentc0d5faa9b4a763befbeab0159d2241a9ddf85b56 (diff)
downloadcpython-37c0844b35b9a4d68f7ddf3a8b38d3e013f17d78.zip
cpython-37c0844b35b9a4d68f7ddf3a8b38d3e013f17d78.tar.gz
cpython-37c0844b35b9a4d68f7ddf3a8b38d3e013f17d78.tar.bz2
Fix SF bug #1167751, Argument genexp corner case
Incorrect code was generated for: foo(a = i for i in range(10)) This should have generated a SyntaxError. Fix the Grammar so it raises a SyntaxError and test it. I'm uncertain whether this should be backported. It makes something that was Syntactically valid invalid. However, the code would either be completely broken or do the wrong thing.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_genexps.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/Lib/test/test_genexps.py b/Lib/test/test_genexps.py
index 894ce6a..7af3ac3 100644
--- a/Lib/test/test_genexps.py
+++ b/Lib/test/test_genexps.py
@@ -82,6 +82,18 @@ Verify that parenthesis are required in a statement
...
SyntaxError: invalid syntax
+Verify that parenthesis are required when used as a keyword argument value
+
+ >>> dict(a = i for i in xrange(10))
+ Traceback (most recent call last):
+ ...
+ SyntaxError: invalid syntax
+
+Verify that parenthesis are required when used as a keyword argument value
+
+ >>> dict(a = (i for i in xrange(10))) #doctest: +ELLIPSIS
+ {'a': <generator object at ...>}
+
Verify early binding for the outermost for-expression
>>> x=10
@@ -125,12 +137,12 @@ Verify that syntax error's are raised for genexps used as lvalues
>>> (y for y in (1,2)) = 10
Traceback (most recent call last):
...
- SyntaxError: assignment to generator expression not possible (<doctest test.test_genexps.__test__.doctests[38]>, line 1)
+ SyntaxError: assignment to generator expression not possible (<doctest test.test_genexps.__test__.doctests[40]>, line 1)
>>> (y for y in (1,2)) += 10
Traceback (most recent call last):
...
- SyntaxError: augmented assignment to generator expression not possible (<doctest test.test_genexps.__test__.doctests[39]>, line 1)
+ SyntaxError: augmented assignment to generator expression not possible (<doctest test.test_genexps.__test__.doctests[41]>, line 1)
########### Tests borrowed from or inspired by test_generators.py ############