summaryrefslogtreecommitdiff
path: root/numpy/lib/npyio.py
diff options
context:
space:
mode:
authorLuis Pedro Coelho <luis@luispedro.org>2019-07-19 17:18:07 +0200
committerLuis Pedro Coelho <luis@luispedro.org>2019-07-20 12:47:47 +0200
commitc4b0b51b5670f0d3720e73588deb42dbef48eb7e (patch)
tree57108628624dd4e896718c9a33401f89d6c5fcb4 /numpy/lib/npyio.py
parentea965e4cd328fbcf76b03ff749ef06d2aa38c28b (diff)
downloadnumpy-c4b0b51b5670f0d3720e73588deb42dbef48eb7e.tar.gz
BUG: Fix file-like object check when saving arrays
For writing arrays, only the ``write`` method is necessary.
Diffstat (limited to 'numpy/lib/npyio.py')
-rw-r--r--numpy/lib/npyio.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py
index 318dc434a..b9dc444f8 100644
--- a/numpy/lib/npyio.py
+++ b/numpy/lib/npyio.py
@@ -521,7 +521,7 @@ def save(file, arr, allow_pickle=True, fix_imports=True):
"""
own_fid = False
- if hasattr(file, 'read'):
+ if hasattr(file, 'write'):
fid = file
else:
file = os_fspath(file)
@@ -709,7 +709,7 @@ def _savez(file, args, kwds, compress, allow_pickle=True, pickle_kwargs=None):
# component of the so-called standard library.
import zipfile
- if not hasattr(file, 'read'):
+ if not hasattr(file, 'write'):
file = os_fspath(file)
if not file.endswith('.npz'):
file = file + '.npz'