[Numpy-svn] r4844 - trunk/numpy/core

numpy-svn at scipy.org numpy-svn at scipy.org
Mon Mar 3 19:21:30 EST 2008


Author: oliphant
Date: 2008-03-03 18:21:29 -0600 (Mon, 03 Mar 2008)
New Revision: 4844

Modified:
   trunk/numpy/core/memmap.py
Log:
Deprecate close method on memmap arrays.

Modified: trunk/numpy/core/memmap.py
===================================================================
--- trunk/numpy/core/memmap.py	2008-03-03 00:42:42 UTC (rev 4843)
+++ trunk/numpy/core/memmap.py	2008-03-04 00:21:29 UTC (rev 4844)
@@ -200,7 +200,7 @@
 
     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 @@
         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




More information about the Numpy-svn mailing list