summaryrefslogtreecommitdiff
path: root/numpy/core/memmap.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/core/memmap.py')
-rw-r--r--numpy/core/memmap.py10
1 files changed, 4 insertions, 6 deletions
diff --git a/numpy/core/memmap.py b/numpy/core/memmap.py
index 831ba3307..3650091bc 100644
--- a/numpy/core/memmap.py
+++ b/numpy/core/memmap.py
@@ -80,10 +80,7 @@ class memmap(ndarray):
if obj is not None:
if not isinstance(obj, memmap):
raise ValueError, "Cannot create a memmap array that way"
- # it would be nice to carry the along the _mmap name
- # but then we might have problems because self could close
- # it while obj is still holding it. So, we don't do
- # anything at this point.
+ self._mmap = obj._mmap
else:
self._mmap = None
@@ -91,9 +88,10 @@ class memmap(ndarray):
self._mmap.flush()
def close(self):
- self._mmap.close()
+ if (self.base is self._mmap):
+ self._mmap.close()
def __del__(self):
if self._mmap is not None:
self._mmap.flush()
- del self._mmap
+ self.close()