소스 검색

pack.FilePackIndex: close mmap object

_load_file_contents may return a mmap object, so self._contents could be
mmap-ed. Close it if so.

Note: we use hasattr() instead of isinstance() for pre-Python 2.6
compatibility (mmap became a class in Python 2.6).
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
Tay Ray Chuan 14 년 전
부모
커밋
f9faace0d4
1개의 변경된 파일2개의 추가작업 그리고 0개의 파일을 삭제
  1. 2 0
      dulwich/pack.py

+ 2 - 0
dulwich/pack.py

@@ -360,6 +360,8 @@ class FilePackIndex(PackIndex):
 
     def close(self):
         self._file.close()
+        if getattr(self._contents, "close", None) is not None:
+            self._contents.close()
 
     def __len__(self):
         """Return the number of entries in this pack index."""