]> granicus.if.org Git - python/commitdiff
This is jiwon's patch to fix:
authorMichael W. Hudson <mwh@python.net>
Mon, 11 Oct 2004 15:35:53 +0000 (15:35 +0000)
committerMichael W. Hudson <mwh@python.net>
Mon, 11 Oct 2004 15:35:53 +0000 (15:35 +0000)
1042238 ] Lib/compiler chokes on certain genexps

Lib/compiler/transformer.py

index 34ad5eadd15912db16f1e2c92e583dc0154df72f..840d79f380fafd12fcc21327194936a143757eb5 100644 (file)
@@ -1165,8 +1165,13 @@ class Transformer:
             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.