mirror of
https://github.com/python/cpython.git
synced 2025-09-18 22:50:26 +00:00
only check the actual compile() call for a SyntaxError
This commit is contained in:
parent
85d6fb5022
commit
248fb1320a
1 changed files with 5 additions and 5 deletions
|
@ -62,12 +62,12 @@ def checker(*suffixes, **kwds):
|
||||||
@checker('.py', severity=4)
|
@checker('.py', severity=4)
|
||||||
def check_syntax(fn, lines):
|
def check_syntax(fn, lines):
|
||||||
"""Check Python examples for valid syntax."""
|
"""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:
|
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')
|
compile(code, fn, 'exec')
|
||||||
except SyntaxError, err:
|
except SyntaxError, err:
|
||||||
yield err.lineno, 'not compilable: %s' % err
|
yield err.lineno, 'not compilable: %s' % err
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue