Skip to content

Remove Python 2 compatibility shims #979

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

Merged
merged 32 commits into from
Feb 8, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Remove compat.byte_ord
  • Loading branch information
Harmon758 committed Feb 7, 2020
commit 584ab08f69ebce31f88f85cad8cee8b678ef9305
4 changes: 0 additions & 4 deletions git/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
defenc = sys.getfilesystemencoding()

if PY3:
def byte_ord(b):
return b

def bchr(n):
return bytes([n])

Expand All @@ -48,7 +45,6 @@ def mviter(d):
else:
if defenc == 'ascii':
defenc = 'utf-8'
byte_ord = ord
bchr = chr
unicode = unicode
binary_type = str
Expand Down
9 changes: 4 additions & 5 deletions git/objects/fun.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Module with functions which are supposed to be as fast as possible"""
from stat import S_ISDIR
from git.compat import (
byte_ord,
safe_decode,
defenc,
xrange,
Expand All @@ -27,7 +26,7 @@ def tree_to_stream(entries, write):
# END for each 8 octal value

# git slices away the first octal if its zero
if byte_ord(mode_str[0]) == ord_zero:
if mode_str[0] == ord_zero:
mode_str = mode_str[1:]
# END save a byte

Expand Down Expand Up @@ -57,10 +56,10 @@ def tree_entries_from_data(data):
# read mode
# Some git versions truncate the leading 0, some don't
# The type will be extracted from the mode later
while byte_ord(data[i]) != space_ord:
while data[i] != space_ord:
# move existing mode integer up one level being 3 bits
# and add the actual ordinal value of the character
mode = (mode << 3) + (byte_ord(data[i]) - ord_zero)
mode = (mode << 3) + (data[i] - ord_zero)
i += 1
# END while reading mode

Expand All @@ -70,7 +69,7 @@ def tree_entries_from_data(data):
# parse name, it is NULL separated

ns = i
while byte_ord(data[i]) != 0:
while data[i] != 0:
i += 1
# END while not reached NULL

Expand Down