summaryrefslogtreecommitdiff
path: root/numpy/lib/npyio.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2021-09-02 10:28:28 -0600
committerGitHub <noreply@github.com>2021-09-02 10:28:28 -0600
commit95d254027f2fb526fe4c745f330e6fa448a7e4db (patch)
treedceb9f90936601187aa6450139cdf26912b4db3b /numpy/lib/npyio.py
parent47368730049ac394c50d2b73fa51e671c1320984 (diff)
parent7ad8ea7b11e3544b133d8b397dd3bbe4833d3308 (diff)
downloadnumpy-95d254027f2fb526fe4c745f330e6fa448a7e4db.tar.gz
Merge pull request #19815 from mwtoews/maint-ioerror
MAINT: revise OSError aliases (IOError, EnvironmentError)
Diffstat (limited to 'numpy/lib/npyio.py')
-rw-r--r--numpy/lib/npyio.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py
index 6f2a211b6..b91bf440f 100644
--- a/numpy/lib/npyio.py
+++ b/numpy/lib/npyio.py
@@ -324,10 +324,12 @@ def load(file, mmap_mode=None, allow_pickle=False, fix_imports=True,
Raises
------
- IOError
+ OSError
If the input file does not exist or cannot be read.
+ UnpicklingError
+ If ``allow_pickle=True``, but the file cannot be loaded as a pickle.
ValueError
- The file contains an object array, but allow_pickle=False given.
+ The file contains an object array, but ``allow_pickle=False`` given.
See Also
--------
@@ -436,8 +438,8 @@ def load(file, mmap_mode=None, allow_pickle=False, fix_imports=True,
try:
return pickle.load(fid, **pickle_kwargs)
except Exception as e:
- raise IOError(
- "Failed to interpret file %s as a pickle" % repr(file)) from e
+ raise pickle.UnpicklingError(
+ f"Failed to interpret file {file!r} as a pickle") from e
def _save_dispatcher(file, arr, allow_pickle=None, fix_imports=None):