Remove Python 2 compatibility shims by Harmon758 · Pull Request #979 · gitpython-developers/GitPython · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ff57c04
Remove str import from builtins
Harmon758 Feb 7, 2020
e0bf255
Remove unnecessary check for sys.getfilesystemencoding
Harmon758 Feb 7, 2020
142c779
Remove and replace compat.FileType
Harmon758 Feb 7, 2020
584ab08
Remove compat.byte_ord
Harmon758 Feb 7, 2020
e564c2f
Remove and replace compat.bchr
Harmon758 Feb 7, 2020
5444787
Remove and replace compat.mviter
Harmon758 Feb 7, 2020
3f21cb1
Remove compat.range
Harmon758 Feb 7, 2020
d0d2a86
Remove and replace compat.xrange
Harmon758 Feb 7, 2020
91e91b2
Remove and replace compat.unicode
Harmon758 Feb 7, 2020
c30880d
Remove Python 2 check for compat.defenc
Harmon758 Feb 7, 2020
2c4d556
Remove and replace compat.binary_type
Harmon758 Feb 7, 2020
8e55323
Remove and replace compat._unichr
Harmon758 Feb 7, 2020
18fc6b2
Remove and replace compat.bytes_chr
Harmon758 Feb 7, 2020
9615ada
Remove surrogateescape error handler for Python 2
Harmon758 Feb 7, 2020
5549ffe
Remove and replace compat.UnicodeMixin
Harmon758 Feb 7, 2020
60c8dc2
Remove checks for Python 2 and/or 3
Harmon758 Feb 7, 2020
6005b89
Remove Python 2 test
Harmon758 Feb 7, 2020
952eaad
Remove compat.PY3
Harmon758 Feb 7, 2020
266187b
Remove and replace compat.MAXSIZE
Harmon758 Feb 7, 2020
8a8b24e
Remove and replace compat.izip
Harmon758 Feb 7, 2020
07df7c9
Remove and replace compat.string_types
Harmon758 Feb 7, 2020
2f31261
Remove and replace compat.text_type
Harmon758 Feb 7, 2020
369de3d
Remove no longer used compat imports
Harmon758 Feb 7, 2020
92348df
Remove no longer used imports in tests
Harmon758 Feb 7, 2020
ebcdb8b
Remove attempt to import ConfigParser for Python 2
Harmon758 Feb 7, 2020
7f250ca
Remove check for Python 2.7
Harmon758 Feb 7, 2020
21d56e2
Remove unnecessary check for logging.NullHandler for Python 2.6
Harmon758 Feb 7, 2020
d96688f
Improve setup.py python_requires
Harmon758 Feb 7, 2020
d0cd5bf
Remove unnecessary check for PermissionError for Python < 3.3
Harmon758 Feb 7, 2020
a611adc
Add to AUTHORS
Harmon758 Feb 7, 2020
d0899a0
Fix requirements.txt formatting
Harmon758 Feb 7, 2020
c5f5911
Remove now unused is_invoking_git variable in test
Harmon758 Feb 7, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
17 changes: 1 addition & 16 deletions git/cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@
from textwrap import dedent

from git.compat import (
string_types,
defenc,
force_bytes,
PY3,
# just to satisfy flake8 on py3
unicode,
safe_decode,
is_posix,
is_win,
Expand All @@ -43,11 +39,6 @@
stream_copy,
)

try:
PermissionError
except NameError: # Python < 3.3
PermissionError = OSError

execute_kwargs = {'istream', 'with_extended_output',
'with_exceptions', 'as_process', 'stdout_as_string',
'output_stream', 'with_stdout', 'kill_after_timeout',
Expand Down Expand Up @@ -918,18 +909,12 @@ def transform_kwargs(self, split_single_char_options=True, **kwargs):
@classmethod
def __unpack_args(cls, arg_list):
if not isinstance(arg_list, (list, tuple)):
# This is just required for unicode conversion, as subprocess can't handle it
# However, in any other case, passing strings (usually utf-8 encoded) is totally fine
if not PY3 and isinstance(arg_list, unicode):
return [arg_list.encode(defenc)]
return [str(arg_list)]

outlist = []
for arg in arg_list:
if isinstance(arg_list, (list, tuple)):
outlist.extend(cls.__unpack_args(arg))
elif not PY3 and isinstance(arg_list, unicode):
outlist.append(arg_list.encode(defenc))
# END recursion
else:
outlist.append(str(arg))
Expand Down Expand Up @@ -1047,7 +1032,7 @@ def _prepare_ref(self, ref):
if isinstance(ref, bytes):
# Assume 40 bytes hexsha - bin-to-ascii for some reason returns bytes, not text
refstr = ref.decode('ascii')
elif not isinstance(ref, string_types):
elif not isinstance(ref, str):
refstr = str(ref) # could be ref-object

if not refstr.endswith("\n"):
Expand Down
254 changes: 4 additions & 250 deletions git/compat.py
Loading