Commit Graph

6 Commits

Author SHA1 Message Date
Georg Brandl 2463f8f831 Make tabnanny recognize IndentationErrors raised by tokenize.
Add a test to test_inspect to make sure indented source
is recognized correctly. (fixes #1224621)
2006-08-14 21:34:08 +00:00
Armin Rigo dd5c023af5 some more fixes and tests for inspect.getsource(), triggered by crashes
from the PyPy project as well as the SF bug #1295909.
2005-09-25 11:45:45 +00:00
Johannes Gijsbers a5855d5ace Patch #1159931/bug #1143895: inspect.getsource failed when functions,
etc., had comments after the colon, and some other cases. This patch
take a simpler approach that doesn't rely on looking for a ':'. Thanks
Simon Percivall!
2005-03-12 16:37:11 +00:00
Tim Peters 5a9fb3c415 Whitespace normalization. 2005-01-07 16:01:32 +00:00
Johannes Gijsbers 1542f34c42 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.

Also add a bunch of
'quite-unlikely-to-occur-in-real-life-but-working-anyway' tests.
2004-12-12 16:46:28 +00:00
Johannes Gijsbers cb9015dc08 Patch #736962: port test_inspect to unittest. As part of this, move out
the fodder modules to separate files to get rid of the imp.load_source()
trickery.
2004-12-12 16:20:22 +00:00