summaryrefslogtreecommitdiff
path: root/numpy/core/memmap.py
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2008-03-04 00:21:29 +0000
committerTravis Oliphant <oliphant@enthought.com>2008-03-04 00:21:29 +0000
commit43cddec31f70e212a5a4b8f748895711bc18c0dc (patch)
treebf4b71f02a08df178e59f0e47ce60f052f5270fa /numpy/core/memmap.py
parent0ccc03e7eb857e0ac69fdccaf7dc9f47640bbd0d (diff)
downloadnumpy-43cddec31f70e212a5a4b8f748895711bc18c0dc.tar.gz
Deprecate close method on memmap arrays.
Diffstat (limited to 'numpy/core/memmap.py')
-rw-r--r--numpy/core/memmap.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/numpy/core/memmap.py b/numpy/core/memmap.py
index b31788881..1c65bccee 100644
--- a/numpy/core/memmap.py
+++ b/numpy/core/memmap.py
@@ -200,7 +200,7 @@ class memmap(ndarray):
def __array_finalize__(self, obj):
self._mmap = None
- if obj is not None and hasattr(obj, '_mmap'):
+ if hasattr(obj, '_mmap'):
self._mmap = obj._mmap
def flush(self):
@@ -213,17 +213,22 @@ class memmap(ndarray):
warnings.warn("Use ``flush``.", DeprecationWarning)
self.flush()
- def close(self):
- """Close the memmap file."""
+ def _close(self):
+ """Close the memmap file. Only do this when deleting the object."""
if self.base is self._mmap:
self._mmap.close()
elif self._mmap is not None:
raise ValueError, "Cannot close a memmap that is being used " \
"by another object."
+ def close(self):
+ """Close the memmap file. Does nothing."""
+ warnings.warn("``close`` is deprecated on memmap arrays. Use del",
+ DeprecationWarning)
+
def __del__(self):
self.flush()
try:
- self.close()
+ self._close()
except ValueError:
pass