diff options
author | Benjamin Peterson <benjamin@python.org> | 2009-01-04 00:39:07 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2009-01-04 00:39:07 (GMT) |
commit | 248fb1320ad89fd28f6d6f4590f9e15ddd85c6e4 (patch) | |
tree | 062a4ed0bc1fe9ece439f9bbd2a5ac9839a5f6c3 /Doc/tools/rstlint.py | |
parent | 85d6fb50221e62e11159ecc915ca3c18d73cfbbb (diff) | |
download | cpython-248fb1320ad89fd28f6d6f4590f9e15ddd85c6e4.zip cpython-248fb1320ad89fd28f6d6f4590f9e15ddd85c6e4.tar.gz cpython-248fb1320ad89fd28f6d6f4590f9e15ddd85c6e4.tar.bz2 |
only check the actual compile() call for a SyntaxError
Diffstat (limited to 'Doc/tools/rstlint.py')
-rwxr-xr-x | Doc/tools/rstlint.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Doc/tools/rstlint.py b/Doc/tools/rstlint.py index 0846d2a..3ea04bd 100755 --- a/Doc/tools/rstlint.py +++ b/Doc/tools/rstlint.py @@ -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 |