Skip to content
This repository was archived by the owner on Jul 26, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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 and replace compat.to_bytes
  • Loading branch information
Harmon758 committed Feb 16, 2020
commit 59c053ee05d6e5f50f8699260aa0e362b567c033
7 changes: 5 additions & 2 deletions gitdb/pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
from binascii import crc32

from gitdb.const import NULL_BYTE
from gitdb.utils.compat import to_bytes

import tempfile
import array
Expand Down Expand Up @@ -877,7 +876,11 @@ def collect_streams_at_offset(self, offset):
stream = streams[-1]
while stream.type_id in delta_types:
if stream.type_id == REF_DELTA:
sindex = self._index.sha_to_index(to_bytes(stream.delta_info))
# smmap can return memory view objects, which can't be compared as buffers/bytes can ...
if isinstance(stream.delta_info, memoryview):
sindex = self._index.sha_to_index(stream.delta_info.tobytes())
else:
sindex = self._index.sha_to_index(stream.delta_info)
if sindex is None:
break
stream = self._pack.stream(self._index.offset(sindex))
Expand Down
11 changes: 0 additions & 11 deletions gitdb/utils/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,6 @@

PY3 = sys.version_info[0] == 3

try:
# Python 2
def to_bytes(i):
return i
except NameError:
# smmap can return memory view objects, which can't be compared as buffers/bytes can ...
def to_bytes(i):
if isinstance(i, memoryview):
return i.tobytes()
return i

try:
MAXSIZE = sys.maxint
except AttributeError:
Expand Down