Skip to content

Commit 2246217

Browse files
authored
burn the bridges with python 2.x (#707)
* pyupgrade --py36-plus * remove handling of PY2 * remove handling of PY35_PLUS * remove handling of PY36_PLUS * remove obsolete version_info checks in pyflakes/ * adjust skips in tests for 3.6+ * is_py3_func -> has_annotations (specifically for lambda) * remove references to py 2 * remove references to unichr * clean up version-specific getattrs * remove unused ReturnWithArgsInsideGenerator * remove unused ast handlers * remove unused RedefinedInListComp
1 parent becbab6 commit 2246217

17 files changed

+203
-639
lines changed

pyflakes/api.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

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

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

1717

1818
def check(codeString, filename, reporter=None):
@@ -48,7 +48,7 @@ def check(codeString, filename, reporter=None):
4848
lines = codeString.splitlines()
4949
if len(lines) >= lineno:
5050
text = lines[lineno - 1]
51-
if sys.version_info >= (3, ) and isinstance(text, bytes):
51+
if isinstance(text, bytes):
5252
try:
5353
text = text.decode('ascii')
5454
except UnicodeDecodeError:
@@ -90,7 +90,7 @@ def checkPath(filename, reporter=None):
9090
try:
9191
with open(filename, 'rb') as f:
9292
codestr = f.read()
93-
except IOError:
93+
except OSError:
9494
msg = sys.exc_info()[1]
9595
reporter.unexpectedError(filename, msg.args[1])
9696
return 1
@@ -113,7 +113,7 @@ def isPythonFile(filename):
113113
text = f.read(max_bytes)
114114
if not text:
115115
return False
116-
except IOError:
116+
except OSError:
117117
return False
118118

119119
return PYTHON_SHEBANG_REGEX.match(text)

0 commit comments

Comments
 (0)