Make tabnanny recognize IndentationErrors raised by tokenize.
Add a test to test_inspect to make sure indented source
is recognized correctly. (fixes #1224621)
diff --git a/Lib/test/inspect_fodder2.py b/Lib/test/inspect_fodder2.py
index f150ec6..3d978cf 100644
--- a/Lib/test/inspect_fodder2.py
+++ b/Lib/test/inspect_fodder2.py
@@ -88,3 +88,12 @@
def func88():
# comment
return 90
+
+# line 92
+def f():
+ class X:
+ def g():
+ "doc"
+ return 42
+ return X
+method_in_dynamic_class = f().g.im_func
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index 300de14..fa4bd40 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -274,6 +274,9 @@
def test_with_comment_instead_of_docstring(self):
self.assertSourceEqual(mod2.func88, 88, 90)
+ def test_method_in_dynamic_class(self):
+ self.assertSourceEqual(mod2.method_in_dynamic_class, 95, 97)
+
# Helper for testing classify_class_attrs.
def attrs_wo_objs(cls):
return [t[:3] for t in inspect.classify_class_attrs(cls)]