diff options
author | Michael W. Hudson <mwh@python.net> | 2004-10-11 15:35:53 (GMT) |
---|---|---|
committer | Michael W. Hudson <mwh@python.net> | 2004-10-11 15:35:53 (GMT) |
commit | c054a8b1a99c15146c9f2092172d04e5c832ffff (patch) | |
tree | 31b5fd9a50127debe666e7778007772d9d2a6ee3 /Lib | |
parent | 29589a06f6fb8298239c26334992d8471ad6f93a (diff) | |
download | cpython-c054a8b1a99c15146c9f2092172d04e5c832ffff.zip cpython-c054a8b1a99c15146c9f2092172d04e5c832ffff.tar.gz cpython-c054a8b1a99c15146c9f2092172d04e5c832ffff.tar.bz2 |
This is jiwon's patch to fix:
[ 1042238 ] Lib/compiler chokes on certain genexps
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/compiler/transformer.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/compiler/transformer.py b/Lib/compiler/transformer.py index 34ad5ea..840d79f 100644 --- a/Lib/compiler/transformer.py +++ b/Lib/compiler/transformer.py @@ -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. |