Skip to content

Commit 248fb13

Browse files
committed
only check the actual compile() call for a SyntaxError
1 parent 85d6fb5 commit 248fb13

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎Doc/tools/rstlint.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ def deco(func):
6262
@checker('.py', severity=4)
6363
def check_syntax(fn, lines):
6464
"""Check Python examples for valid syntax."""
65+
code = ''.join(lines)
66+
if '\r' in code:
67+
if os.name != 'nt':
68+
yield 0, '\\r in code file'
69+
code = code.replace('\r', '')
6570
try:
66-
code = ''.join(lines)
67-
if '\r' in code:
68-
if os.name != 'nt':
69-
yield 0, '\\r in code file'
70-
code = code.replace('\r', '')
7171
compile(code, fn, 'exec')
7272
except SyntaxError, err:
7373
yield err.lineno, 'not compilable: %s' % err

0 commit comments

Comments
 (0)