This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Lib/compiler chokes on certain genexps
Type: Stage:
Components: None Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: mwh Nosy List: anthonybaxter, jiwon, mwh, rhettinger
Priority: critical Keywords:

Created on 2004-10-07 13:35 by mwh, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
transfomer2.diff mwh, 2004-10-11 14:31 jiwon's patch
Messages (9)
msg22624 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2004-10-07 13:35
Noticed this because test_compiler fails on _strptime
as of yesterday.

Here's what seems to be a fairly minimal example: 

f((x for x in y), 1)

The traceback is huge, but ends with:

  File
"/home/mwh/src/python/dist/src/Lib/compiler/transformer.py",
line 687, in power
    node = self.com_apply_trailer(node, elt)
  File
"/home/mwh/src/python/dist/src/Lib/compiler/transformer.py",
line 1144, in com_apply_trailer
    return self.com_call_function(primaryNode, nodelist[2])
  File
"/home/mwh/src/python/dist/src/Lib/compiler/transformer.py",
line 1169, in com_call_function
    raise SyntaxError, 'generator expression needs
parenthesis'
SyntaxError: generator expression needs parenthesis

Might be a problem in transformer.py, not really sure.
msg22625 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2004-10-07 13:38
Logged In: YES 
user_id=6656

Hang on, the exception is *inside* transformer.py.  Duh.
msg22626 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2004-10-10 08:07
Logged In: YES 
user_id=80475

Do you know how to fix this?
msg22627 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2004-10-11 12:07
Logged In: YES 
user_id=6656

No.  I'm hoping jiwon (he who wrote the genexps patch) does
-- I've sent him a mail.
msg22628 - (view) Author: Anthony Baxter (anthonybaxter) (Python triager) Date: 2004-10-11 13:09
Logged In: YES 
user_id=29957

Failing case, distilled down:

import compiler
a="""def foo(*x): return x
foo((a for b in [[1,2,3],[4,5,6]] for a in b),'Z')"""
compiler.compile(a,'<string>', 'exec')

msg22629 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2004-10-11 13:12
Logged In: YES 
user_id=6656

Rather more minimal example:

from compiler import transformer
transformer.parse("f((x for x in y), 1)")

The problem is in transformer.py.
msg22630 - (view) Author: Jiwon Seo (jiwon) * Date: 2004-10-11 14:24
Logged In: YES 
user_id=595483

I fixed the bug. The bug was due to the wrong check
condition for allowing "f(x for x in y)", but rejecting "f(x
for x in y, 1)"

The patch is
http://seojiwon.dnip.net:8000/~jiwon/transformer.diff

I hope mwh will upload that file here, since I don't have
the permission.
msg22631 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2004-10-11 14:31
Logged In: YES 
user_id=6656

Attaching Jiwon's patch (after converting it to a context
diff, *thwack* :-)
msg22632 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2004-10-11 15:36
Logged In: YES 
user_id=6656

Checked in jiwon's fix as Lib/compiler/transformer.py
revision 1.48.
History
Date User Action Args
2022-04-11 14:56:07adminsetgithub: 40990
2004-10-07 13:35:36mwhcreate