Kaydet (Commit) 248fb132 authored tarafından Benjamin Peterson's avatar Benjamin Peterson

only check the actual compile() call for a SyntaxError

üst 85d6fb50
...@@ -62,12 +62,12 @@ def checker(*suffixes, **kwds): ...@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment