[ python-Bugs-1143895 ] inspect.getsource() breakage in 2.4

SourceForge.net noreply at sourceforge.net
Wed Mar 9 16:40:00 CET 2005


Bugs item #1143895, was opened at 2005-02-18 17:26
Message generated for change (Comment added) made by percivall
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1143895&group_id=5470

Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 7
Submitted By: Armin Rigo (arigo)
Assigned to: Nobody/Anonymous (nobody)
Summary: inspect.getsource() breakage in 2.4

Initial Comment:
In a real-life case, inspect.getsource() used to
produce the correct result on 2.3 but no longer does on
2.4:

def somefunc(x, y):  # comments
     ...body...

With 2.4 (and 2.5 CVS) the body is completely skipped
because the first line doesn't end with a colon.  In my
opinion that's a critical problem for any code relying
on getsource(), even though such code can be considered
as relying on a large pile of fragile hacks in the
first place...

Attached is a patch for test_inspect.py, showing the
problem (also includes a different, much more
convoluted bug example).  It seems that looking for and
around ':' in the first line isn't such a good idea;
relying more fully on the tokenizer would probably be a
better solution.

Assigned to jlgijsbers, as the author of the changes
that broke this (Dec 12th, 2004).  (No blame intended,
the change was meant to fix a different bug, and it did
so.)

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

Comment By: Simon Percivall (percivall)
Date: 2005-03-09 16:40

Message:
Logged In: YES 
user_id=329382

Patch http://www.python.org/sf/1159931 fixes this problem.

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

Comment By: Johannes Gijsbers (jlgijsbers)
Date: 2005-03-09 12:26

Message:
Logged In: YES 
user_id=469548

Well, I'm sorry, but I can't make the time after all. I've
asked the author of the original patch to take a look at
this patch. Note that this code isn't yet in a 2.4 release,
so we could also back this out before 2.4.1.

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

Comment By: Johannes Gijsbers (jlgijsbers)
Date: 2005-02-18 20:11

Message:
Logged In: YES 
user_id=469548

Right now I don't have time to look into this bug deeply,
but I will do so this week. I'll note that the convoluted
example doesn't seem to be working under 2.3, though.

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

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


More information about the Python-bugs-list mailing list