From 248fb1320ad89fd28f6d6f4590f9e15ddd85c6e4 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Sun, 4 Jan 2009 00:39:07 +0000 Subject: [PATCH] only check the actual compile() call for a SyntaxError --- Doc/tools/rstlint.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Doc/tools/rstlint.py b/Doc/tools/rstlint.py index 0846d2a8a34..3ea04bdecc5 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