[Python-checkins] python/dist/src/Lib/compiler transformer.py, 1.47, 1.48

mwh at users.sourceforge.net mwh at users.sourceforge.net
Mon Oct 11 17:35:55 CEST 2004


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

Modified Files:
	transformer.py 
Log Message:
This is jiwon's patch to fix:

[ 1042238 ] Lib/compiler chokes on certain genexps


Index: transformer.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/compiler/transformer.py,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- transformer.py	12 Sep 2004 03:49:30 -0000	1.47
+++ transformer.py	11 Oct 2004 15:35:53 -0000	1.48
@@ -1165,8 +1165,13 @@
             if node[0] == token.STAR or node[0] == token.DOUBLESTAR:
                 break
             kw, result = self.com_argument(node, kw)
-            if len_nodelist != 2 and isinstance(result, GenExpr):
+
+            if len_nodelist != 2 and isinstance(result, GenExpr) \
+               and len(node) == 3 and node[2][0] == symbol.gen_for:
+                # allow f(x for x in y), but reject f(x for x in y, 1)
+                # should use f((x for x in y), 1) instead of f(x for x in y, 1)
                 raise SyntaxError, 'generator expression needs parenthesis'
+
             args.append(result)
         else:
             # No broken by star arg, so skip the last one we processed.



More information about the Python-checkins mailing list