]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
Patch #1011890: fix inspect.getsource breaking with line-continuation &
authorJohannes Gijsbers <jlg@dds.nl>
Fri, 31 Dec 2004 09:45:37 +0000 (09:45 +0000)
committerJohannes Gijsbers <jlg@dds.nl>
Fri, 31 Dec 2004 09:45:37 +0000 (09:45 +0000)
commit01b53e1f068d20ce3a9dace58f45be82b7eb85c6
tree3d0fc70c5afb7a8c80223985e941fa918c97c52a
parent4dc49d6123b77f7c853c840cecb8e6def2e45021
Patch #1011890: fix inspect.getsource breaking with line-continuation &
more. Thanks to Simon Percivall!

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.

Don't backport the tests, as these have been too heavily modified on the trunk.
Lib/inspect.py