summaryrefslogtreecommitdiffstats
path: root/Lib/test/inspect_fodder2.py
diff options
context:
space:
mode:
authorJohannes Gijsbers <jlg@dds.nl>2004-12-12 16:46:28 (GMT)
committerJohannes Gijsbers <jlg@dds.nl>2004-12-12 16:46:28 (GMT)
commit1542f34c42de544cf11e400906149c6252b42ae7 (patch)
tree6c30eb80e493d287218d40679afd432e02f3d9b7 /Lib/test/inspect_fodder2.py
parentcb9015dc088676e7fa6434081d105068cded7743 (diff)
downloadcpython-1542f34c42de544cf11e400906149c6252b42ae7.zip
cpython-1542f34c42de544cf11e400906149c6252b42ae7.tar.gz
cpython-1542f34c42de544cf11e400906149c6252b42ae7.tar.bz2
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.
Diffstat (limited to 'Lib/test/inspect_fodder2.py')
-rw-r--r--Lib/test/inspect_fodder2.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/Lib/test/inspect_fodder2.py b/Lib/test/inspect_fodder2.py
index 19da352..ce42929 100644
--- a/Lib/test/inspect_fodder2.py
+++ b/Lib/test/inspect_fodder2.py
@@ -20,3 +20,36 @@ def wrapped():
@replace
def gone():
pass
+
+# line 24
+oll = lambda m: m
+
+# line 27
+tll = lambda g: g and \
+g and \
+g
+
+# line 32
+tlli = lambda d: d and \
+ d
+
+# line 36
+def onelinefunc(): pass
+
+# line 39
+def manyargs(arg1, arg2,
+arg3, arg4): pass
+
+# line 43
+def twolinefunc(m): return m and \
+m
+
+# line 47
+a = [None,
+ lambda x: x,
+ None]
+
+# line 52
+def setfunc(func):
+ globals()["anonymous"] = func
+setfunc(lambda x, y: x*y)