summaryrefslogtreecommitdiff
path: root/numpy/lib/npyio.py
diff options
context:
space:
mode:
authorMike Taves <mwtoews@gmail.com>2021-09-02 21:32:21 +1200
committerMike Taves <mwtoews@gmail.com>2021-09-02 22:56:43 +1200
commit7ad8ea7b11e3544b133d8b397dd3bbe4833d3308 (patch)
tree8726a71692b20b079cec53e76f5c1fb33c806d7b /numpy/lib/npyio.py
parent9fca8f0c1a3f16f8f62ae574ec1a79b5b588214e (diff)
downloadnumpy-7ad8ea7b11e3544b133d8b397dd3bbe4833d3308.tar.gz
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):