]> granicus.if.org Git - python/commitdiff
only check the actual compile() call for a SyntaxError
authorBenjamin Peterson <benjamin@python.org>
Sun, 4 Jan 2009 00:39:07 +0000 (00:39 +0000)
committerBenjamin Peterson <benjamin@python.org>
Sun, 4 Jan 2009 00:39:07 +0000 (00:39 +0000)
Doc/tools/rstlint.py

index 0846d2a8a348111a0a5b46a8eaaf0ca47ae46151..3ea04bdecc5f107d91f10242a8b03fab24f31d25 100755 (executable)
@@ -62,12 +62,12 @@ def checker(*suffixes, **kwds):
 @checker('.py', severity=4)
 def check_syntax(fn, lines):
     """Check Python examples for valid syntax."""
+    code = ''.join(lines)
+    if '\r' in code:
+        if os.name != 'nt':
+            yield 0, '\\r in code file'
+        code = code.replace('\r', '')
     try:
-        code = ''.join(lines)
-        if '\r' in code:
-            if os.name != 'nt':
-                yield 0, '\\r in code file'
-            code = code.replace('\r', '')
         compile(code, fn, 'exec')
     except SyntaxError, err:
         yield err.lineno, 'not compilable: %s' % err