diff options
author | Anthony Sottile <asottile@umich.edu> | 2022-07-18 23:31:47 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-18 23:31:47 -0400 |
commit | a153aeed8df60f4190e6114f77cd254d1493e411 (patch) | |
tree | 6926a3feedce4a582e70a80ce178d627c1766241 /pyflakes/api.py | |
parent | d875b02835fb9b1480a95c5245040eb31a384357 (diff) | |
download | pyflakes-a153aeed8df60f4190e6114f77cd254d1493e411.tar.gz |
remove special handling of pypy offsets since modern pypy gets it right (#717)
Diffstat (limited to 'pyflakes/api.py')
-rw-r--r-- | pyflakes/api.py | 26 |
1 files changed, 4 insertions, 22 deletions
diff --git a/pyflakes/api.py b/pyflakes/api.py index a2a5896..b701ec5 100644 --- a/pyflakes/api.py +++ b/pyflakes/api.py @@ -37,25 +37,8 @@ def check(codeString, filename, reporter=None): # First, compile into an AST and handle syntax errors. try: tree = ast.parse(codeString, filename=filename) - except SyntaxError: - value = sys.exc_info()[1] - msg = value.args[0] - - (lineno, offset, text) = value.lineno, value.offset, value.text - - if checker.PYPY: - if text is None: - lines = codeString.splitlines() - if len(lines) >= lineno: - text = lines[lineno - 1] - if isinstance(text, bytes): - try: - text = text.decode('ascii') - except UnicodeDecodeError: - text = None - offset -= 1 - - reporter.syntaxError(filename, msg, lineno, offset, text) + except SyntaxError as e: + reporter.syntaxError(filename, e.args[0], e.lineno, e.offset, e.text) return 1 except Exception: reporter.unexpectedError(filename, 'problem decoding source') @@ -83,9 +66,8 @@ def checkPath(filename, reporter=None): try: with open(filename, 'rb') as f: codestr = f.read() - except OSError: - msg = sys.exc_info()[1] - reporter.unexpectedError(filename, msg.args[1]) + except OSError as e: + reporter.unexpectedError(filename, e.args[1]) return 1 return check(codestr, filename, reporter) |