[Patches] [ python-Patches-1011890 ] fix inspect.getsource breaking with line-continuation & more

SourceForge.net noreply at sourceforge.net
Thu Aug 19 03:11:10 CEST 2004


Patches item #1011890, was opened at 2004-08-19 03:11
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1011890&group_id=5470

Category: Library (Lib)
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Simon Percivall (percivall)
Assigned to: Nobody/Anonymous (nobody)
Summary: fix inspect.getsource breaking with line-continuation & more

Initial Comment:
The patch makes changes to inspect.py in two places:

* the pattern to match against functions at line 436 is
modified: lambdas should be matched even if not
preceded by whitespace, as long as "lambda" isn't part
of another word.

* the BlockFinder class is heavily modified. Changes are: 
  - checking for "def", "class" or "lambda" names
before setting self.started to True. Then checking the
same line for word characters after the colon (if the
colon is on that line). If so, and the line does not
end with a line continuation marker, raise EndOfBlock
immediately.
  - adding self.passline to show that the line is to be
included and no more checking is necessary on that
line. Since a NEWLINE token is not generated when a
line continuation marker exists, this allows getsource
to continue with these functions even if the following
line would not be indented.

The patch might be making a mess of the simple code,
and code such as code it now handles will probably not
be seen often. Still, it fixes the first bug shown in
"www.python.org/sf/769569".

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

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


More information about the Patches mailing list