From: Benjamin Peterson Date: Sun, 4 Jan 2009 00:39:07 +0000 (+0000) Subject: only check the actual compile() call for a SyntaxError X-Git-Tag: v2.7a1~2391 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=248fb1320ad89fd28f6d6f4590f9e15ddd85c6e4;p=thirdparty%2FPython%2Fcpython.git only check the actual compile() call for a SyntaxError --- diff --git a/Doc/tools/rstlint.py b/Doc/tools/rstlint.py index 0846d2a8a348..3ea04bdecc5f 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