diff options
Diffstat (limited to 'numpy/core/memmap.py')
-rw-r--r-- | numpy/core/memmap.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/numpy/core/memmap.py b/numpy/core/memmap.py index 53f9a3f07..fe52b3a09 100644 --- a/numpy/core/memmap.py +++ b/numpy/core/memmap.py @@ -203,8 +203,10 @@ class memmap(ndarray): if hasattr(filename,'read'): fid = filename + own_file = False else: fid = open(filename, (mode == 'c' and 'r' or mode)+'b') + own_file = True if (mode == 'w+') and shape is None: raise ValueError("shape must be given") @@ -263,6 +265,9 @@ class memmap(ndarray): elif hasattr(filename, "name"): self.filename = os.path.abspath(filename.name) + if own_file: + fid.close() + return self def __array_finalize__(self, obj): |