[ python-Bugs-1042238 ] Lib/compiler chokes on certain genexps

SourceForge.net noreply at sourceforge.net
Mon Oct 11 17:36:39 CEST 2004


Bugs item #1042238, was opened at 2004-10-07 14:35
Message generated for change (Comment added) made by mwh
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1042238&group_id=5470

Category: None
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 9
Submitted By: Michael Hudson (mwh)
>Assigned to: Michael Hudson (mwh)
Summary: Lib/compiler chokes on certain genexps

Initial Comment:
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.

----------------------------------------------------------------------

>Comment By: Michael Hudson (mwh)
Date: 2004-10-11 16:36

Message:
Logged In: YES 
user_id=6656

Checked in jiwon's fix as Lib/compiler/transformer.py
revision 1.48.

----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2004-10-11 15:31

Message:
Logged In: YES 
user_id=6656

Attaching Jiwon's patch (after converting it to a context
diff, *thwack* :-)

----------------------------------------------------------------------

Comment By: Jiwon Seo (jiwon)
Date: 2004-10-11 15:24

Message:
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.

----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2004-10-11 14:12

Message:
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.

----------------------------------------------------------------------

Comment By: Anthony Baxter (anthonybaxter)
Date: 2004-10-11 14:09

Message:
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')



----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2004-10-11 13:07

Message:
Logged In: YES 
user_id=6656

No.  I'm hoping jiwon (he who wrote the genexps patch) does
-- I've sent him a mail.

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2004-10-10 09:07

Message:
Logged In: YES 
user_id=80475

Do you know how to fix this?

----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2004-10-07 14:38

Message:
Logged In: YES 
user_id=6656

Hang on, the exception is *inside* transformer.py.  Duh.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1042238&group_id=5470


More information about the Python-bugs-list mailing list