Skip to content
This repository was archived by the owner on Apr 14, 2024. It is now read-only.

Commit be29427

Browse files
committed
Protected stream closure against possibilty of being a bytes
For some reason, it gets bytes where it did expect a stream ... . Probably I should have figured out where this was input, instead of fixing it the brutal way
1 parent 560a211 commit be29427

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

‎gitdb/db/loose.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ def info(self, sha):
159159
typ, size = loose_object_header_info(m)
160160
return OInfo(sha, typ, size)
161161
finally:
162-
m.close()
162+
if hasattr(m, 'close'):
163+
m.close()
163164
# END assure release of system resources
164165

165166
def stream(self, sha):

‎gitdb/stream.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ def close(self):
145145
:note: can be called safely
146146
"""
147147
if self._close:
148-
self._m.close()
148+
if hasattr(self._m, 'close'):
149+
self._m.close()
149150
self._close = False
150151
# END handle resource freeing
151152

0 commit comments

Comments
 (0)