Skip to content

Commit 59c053e

Browse files
committed
Remove and replace compat.to_bytes
1 parent d1c20d5 commit 59c053e

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

Diff for: gitdb/pack.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
from binascii import crc32
6363

6464
from gitdb.const import NULL_BYTE
65-
from gitdb.utils.compat import to_bytes
6665

6766
import tempfile
6867
import array
@@ -877,7 +876,11 @@ def collect_streams_at_offset(self, offset):
877876
stream = streams[-1]
878877
while stream.type_id in delta_types:
879878
if stream.type_id == REF_DELTA:
880-
sindex = self._index.sha_to_index(to_bytes(stream.delta_info))
879+
# smmap can return memory view objects, which can't be compared as buffers/bytes can ...
880+
if isinstance(stream.delta_info, memoryview):
881+
sindex = self._index.sha_to_index(stream.delta_info.tobytes())
882+
else:
883+
sindex = self._index.sha_to_index(stream.delta_info)
881884
if sindex is None:
882885
break
883886
stream = self._pack.stream(self._index.offset(sindex))

Diff for: gitdb/utils/compat.py

-11
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,6 @@
22

33
PY3 = sys.version_info[0] == 3
44

5-
try:
6-
# Python 2
7-
def to_bytes(i):
8-
return i
9-
except NameError:
10-
# smmap can return memory view objects, which can't be compared as buffers/bytes can ...
11-
def to_bytes(i):
12-
if isinstance(i, memoryview):
13-
return i.tobytes()
14-
return i
15-
165
try:
176
MAXSIZE = sys.maxint
187
except AttributeError:

0 commit comments

Comments
 (0)