summaryrefslogtreecommitdiff
path: root/pyflakes/api.py
diff options
context:
space:
mode:
authorJohn Vandenberg <jayvdb@gmail.com>2015-11-19 18:44:21 +1100
committerJohn Vandenberg <jayvdb@gmail.com>2015-11-20 02:00:32 +1100
commit3088ffbd6256521e0213b361bc2294c1e218e6fb (patch)
tree92065e50216c492e8b2dc5ff5039d2e1c313de4d /pyflakes/api.py
parent02f55ed784db600d02ae130ec325ac37d44322a9 (diff)
downloadpyflakes-3088ffbd6256521e0213b361bc2294c1e218e6fb.tar.gz
Fix PyPy
Diffstat (limited to 'pyflakes/api.py')
-rw-r--r--pyflakes/api.py12
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