[Python-checkins] r68288 - python/trunk/Doc/tools/rstlint.py
benjamin.peterson
python-checkins at python.org
Sun Jan 4 01:39:08 CET 2009
Author: benjamin.peterson
Date: Sun Jan 4 01:39:07 2009
New Revision: 68288
Log:
only check the actual compile() call for a SyntaxError
Modified:
python/trunk/Doc/tools/rstlint.py
Modified: python/trunk/Doc/tools/rstlint.py
==============================================================================
--- python/trunk/Doc/tools/rstlint.py (original)
+++ python/trunk/Doc/tools/rstlint.py Sun Jan 4 01:39:07 2009
@@ -62,12 +62,12 @@
@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
More information about the Python-checkins
mailing list