[Python-checkins] r51284 - in python/trunk/Lib: tabnanny.py test/inspect_fodder2.py test/test_inspect.py tokenize.py

georg.brandl python-checkins at python.org
Mon Aug 14 23:34:09 CEST 2006


Author: georg.brandl
Date: Mon Aug 14 23:34:08 2006
New Revision: 51284
Modified:
 python/trunk/Lib/tabnanny.py
 python/trunk/Lib/test/inspect_fodder2.py
 python/trunk/Lib/test/test_inspect.py
 python/trunk/Lib/tokenize.py
Log:
Make tabnanny recognize IndentationErrors raised by tokenize.
Add a test to test_inspect to make sure indented source
is recognized correctly. (fixes #1224621)
Modified: python/trunk/Lib/tabnanny.py
==============================================================================
--- python/trunk/Lib/tabnanny.py	(original)
+++ python/trunk/Lib/tabnanny.py	Mon Aug 14 23:34:08 2006
@@ -109,6 +109,10 @@
 errprint("%r: Token Error: %s" % (file, msg))
 return
 
+ except IndentationError, msg:
+ errprint("%r: Indentation Error: %s" % (file, msg))
+ return
+
 except NannyNag, nag:
 badline = nag.get_lineno()
 line = nag.get_line()
Modified: python/trunk/Lib/test/inspect_fodder2.py
==============================================================================
--- python/trunk/Lib/test/inspect_fodder2.py	(original)
+++ python/trunk/Lib/test/inspect_fodder2.py	Mon Aug 14 23:34:08 2006
@@ -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
Modified: python/trunk/Lib/test/test_inspect.py
==============================================================================
--- python/trunk/Lib/test/test_inspect.py	(original)
+++ python/trunk/Lib/test/test_inspect.py	Mon Aug 14 23:34:08 2006
@@ -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)]
Modified: python/trunk/Lib/tokenize.py
==============================================================================
--- python/trunk/Lib/tokenize.py	(original)
+++ python/trunk/Lib/tokenize.py	Mon Aug 14 23:34:08 2006
@@ -273,7 +273,8 @@
 while column < indents[-1]:
 if column not in indents:
 raise IndentationError(
- "unindent does not match any outer indentation level")
+ "unindent does not match any outer indentation level",
+ ("<tokenize>", lnum, pos, line))
 indents = indents[:-1]
 yield (DEDENT, '', (lnum, pos), (lnum, pos), line)
 


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /