[Python-checkins] python/dist/src/Lib/test test_genexps.py, 1.9, 1.10

nnorwitz@users.sourceforge.net nnorwitz at users.sourceforge.net
Fri Oct 21 08:24:05 CEST 2005


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8692/Lib/test

Modified Files:
	test_genexps.py 
Log Message:
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.


Index: test_genexps.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_genexps.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- test_genexps.py	20 Oct 2005 19:59:24 -0000	1.9
+++ test_genexps.py	21 Oct 2005 06:24:02 -0000	1.10
@@ -82,6 +82,18 @@
        ...
     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 @@
     >>> (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 ############



More information about the Python-checkins mailing list