-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drop support for Python 2.7 up to 3.6.
- Loading branch information
Michael Howitz
committed
May 24, 2023
1 parent
f7b3a32
commit 4eafe1e
Showing
13 changed files
with
153 additions
and
230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,10 @@ | ||
import sys | ||
|
||
|
||
PY3 = sys.version_info[0] == 3 | ||
JYTHON = sys.platform.startswith('java') | ||
|
||
if PY3: # pragma: no cover | ||
text_type = str | ||
else: # pragma: no cover | ||
# py2 | ||
text_type = unicode # noqa: F821 undefined name 'unicode' | ||
|
||
|
||
def text_(s): | ||
if not isinstance(s, text_type): # pragma: no cover | ||
if not isinstance(s, str): # pragma: no cover | ||
s = s.decode('utf-8') | ||
return s | ||
|
||
|
||
if PY3: # pragma: no cover | ||
def native_(s, encoding='latin-1', errors='strict'): | ||
if isinstance(s, text_type): | ||
return s | ||
return str(s, encoding, errors) | ||
else: # pragma: no cover | ||
def native_(s, encoding='latin-1', errors='strict'): | ||
if isinstance(s, text_type): | ||
return s.encode(encoding, errors) | ||
return str(s) | ||
|
||
if PY3: # pragma: no cover | ||
from io import StringIO | ||
else: # pragma: no cover | ||
from io import BytesIO | ||
|
||
# Prevent crashes in IPython when writing tracebacks if a commit fails | ||
# ref: | ||
# https://github.com/ipython/ipython/issues/9126#issuecomment-174966638 | ||
|
||
class StringIO(BytesIO): | ||
def write(self, s): | ||
s = native_(s, encoding='utf-8') | ||
super(StringIO, self).write(s) | ||
|
||
|
||
if PY3: # pragma: no cover | ||
def reraise(tp, value, tb=None): | ||
if value.__traceback__ is not tb: # pragma: no cover | ||
raise value.with_traceback(tb) | ||
raise value | ||
|
||
else: # pragma: no cover | ||
def exec_(code, globs=None, locs=None): | ||
"""Execute code in a namespace.""" | ||
if globs is None: | ||
frame = sys._getframe(1) | ||
globs = frame.f_globals | ||
if locs is None: | ||
locs = frame.f_locals | ||
del frame | ||
elif locs is None: | ||
locs = globs | ||
exec("""exec code in globs, locs""") | ||
|
||
exec_("""def reraise(tp, value, tb=None): | ||
raise tp, value, tb | ||
""") | ||
|
||
# isort: off | ||
|
||
try: # pragma: no cover | ||
from threading import get_ident as get_thread_ident | ||
except ImportError: # pragma: no cover | ||
# PY2 | ||
from thread import get_ident as get_thread_ident # noqa: F401 unused | ||
def native_(s, encoding='latin-1', errors='strict'): | ||
if isinstance(s, str): | ||
return s | ||
return str(s, encoding, errors) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.