Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

burn the bridges with python 2.x #707

Merged
merged 13 commits into from Jun 12, 2022
8 changes: 4 additions & 4 deletions pyflakes/api.py
Expand Up @@ -12,7 +12,7 @@

__all__ = ['check', 'checkPath', 'checkRecursive', 'iterSourceCode', 'main']

PYTHON_SHEBANG_REGEX = re.compile(br'^#!.*\bpython([23](\.\d+)?|w)?[dmu]?\s')
PYTHON_SHEBANG_REGEX = re.compile(br'^#!.*\bpython(3(\.\d+)?|w)?[dmu]?\s')


def check(codeString, filename, reporter=None):
Expand Down Expand Up @@ -48,7 +48,7 @@ def check(codeString, filename, reporter=None):
lines = codeString.splitlines()
if len(lines) >= lineno:
text = lines[lineno - 1]
if sys.version_info >= (3, ) and isinstance(text, bytes):
if isinstance(text, bytes):
try:
text = text.decode('ascii')
except UnicodeDecodeError:
Expand Down Expand Up @@ -90,7 +90,7 @@ def checkPath(filename, reporter=None):
try:
with open(filename, 'rb') as f:
codestr = f.read()
except IOError:
except OSError:
msg = sys.exc_info()[1]
reporter.unexpectedError(filename, msg.args[1])
return 1
Expand All @@ -113,7 +113,7 @@ def isPythonFile(filename):
text = f.read(max_bytes)
if not text:
return False
except IOError:
except OSError:
return False

return PYTHON_SHEBANG_REGEX.match(text)
Expand Down