Skip to content

Commit 449e80b

Browse files
committed
byteswapping in offsets method will only be done if required - previously it was always performed even though the byte order of the system didn't require it
1 parent 18152fe commit 449e80b

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

pack.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
from itertools import izip
5353
import array
5454
import os
55+
import sys
56+
5557
__all__ = ('PackIndexFile', 'PackFile', 'PackEntity')
5658

5759

@@ -272,7 +274,8 @@ def offsets(self):
272274
a.fromstring(buffer(self._data, self._pack_offset, self._pack_64_offset - self._pack_offset))
273275

274276
# networkbyteorder to something array likes more
275-
a.byteswap()
277+
if sys.byteorder == 'little':
278+
a.byteswap()
276279
return a
277280
else:
278281
return tuple(self.offset(index) for index in xrange(self.size()))

test/test_example.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@ def test_base(self):
2222
assert ldb.has_object(oinfo.binsha)
2323
# END for each sha in database
2424
# assure we close all files
25-
del(ostream)
26-
del(oinfo)
27-
25+
try:
26+
del(ostream)
27+
del(oinfo)
28+
except UnboundLocalError:
29+
pass
30+
# END ignore exception if there are no loose objects
31+
2832
data = "my data"
2933
istream = IStream("blob", len(data), StringIO(data))
3034

0 commit comments

Comments
 (0)