浏览代码

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."""