summaryrefslogtreecommitdiff
path: root/numpy/core/memmap.py
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2007-09-21 17:32:21 +0000
committerTravis Oliphant <oliphant@enthought.com>2007-09-21 17:32:21 +0000
commit5f83bc06514b922cc6a56f4c33337f4ba8c6cdda (patch)
treec2582dcb8a03bc30c264d6df28c4e06f7e47bd74 /numpy/core/memmap.py
parent6f149aaca13e603763a9c4a7347d605daaf4829d (diff)
downloadnumpy-5f83bc06514b922cc6a56f4c33337f4ba8c6cdda.tar.gz
A little refactoring of memmap
Diffstat (limited to 'numpy/core/memmap.py')
-rw-r--r--numpy/core/memmap.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/numpy/core/memmap.py b/numpy/core/memmap.py
index 7063cf661..1b007c957 100644
--- a/numpy/core/memmap.py
+++ b/numpy/core/memmap.py
@@ -85,19 +85,20 @@ class memmap(ndarray):
self._mmap = None
def sync(self):
- self._mmap.flush()
+ if self._mmap is not None:
+ self._mmap.flush()
def close(self):
if (self.base is self._mmap):
self._mmap.close()
- else:
+ elif self._mmap is not None:
raise ValueError, "Cannot close a memmap that is being used " \
"by another object."
def __del__(self):
- if self._mmap is not None:
- self._mmap.flush()
- try:
- self.close()
- except:
- pass
+ self.sync()
+ try:
+ self.close()
+ except ValueError:
+ pass
+