diff options
author | John Vandenberg <jayvdb@gmail.com> | 2015-11-19 18:44:21 +1100 |
---|---|---|
committer | John Vandenberg <jayvdb@gmail.com> | 2015-11-20 02:00:32 +1100 |
commit | 3088ffbd6256521e0213b361bc2294c1e218e6fb (patch) | |
tree | 92065e50216c492e8b2dc5ff5039d2e1c313de4d /pyflakes/api.py | |
parent | 02f55ed784db600d02ae130ec325ac37d44322a9 (diff) | |
download | pyflakes-3088ffbd6256521e0213b361bc2294c1e218e6fb.tar.gz |
Fix PyPy
Diffstat (limited to 'pyflakes/api.py')
-rw-r--r-- | pyflakes/api.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/pyflakes/api.py b/pyflakes/api.py index 3bc2330..2a46a0d 100644 --- a/pyflakes/api.py +++ b/pyflakes/api.py @@ -41,6 +41,18 @@ def check(codeString, filename, reporter=None): (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 sys.version_info >= (3, ) and isinstance(text, bytes): + try: + text = text.decode('ascii') + except UnicodeDecodeError: + text = None + offset -= 1 + # If there's an encoding problem with the file, the text is None. if text is None: # Avoid using msg, since for the only known case, it contains a |