summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorNoƩ Rubinstein <noe.rubinstein@gmail.com>2023-01-27 19:39:38 +0100
committerGitHub <noreply@github.com>2023-01-27 19:39:38 +0100
commit41499995a4c532556b2b6d6e3c0fabb0a7bdb61a (patch)
tree9776bca523d90e02388442a38740a04eb4d41731 /doc
parent2289292db6a19f2bbfddd3dea3790ffa19955333 (diff)
downloadnumpy-41499995a4c532556b2b6d6e3c0fabb0a7bdb61a.tar.gz
API: Raise EOFError when trying to load past the end of a `.npy` file (#23105)
Currently, the following code: ``` import numpy as np with open('foo.npy', 'wb') as f: for i in range(np.random.randint(10)): np.save(f, 1) with open('foo.npy', 'rb') as f: while True: np.load(f) ``` Will raise: ``` ValueError: Cannot load file containing pickled data when allow_pickle=False ``` While there is no pickled data in the file.
Diffstat (limited to 'doc')
-rw-r--r--doc/release/upcoming_changes/23105.compatibility.rst5
1 files changed, 5 insertions, 0 deletions
diff --git a/doc/release/upcoming_changes/23105.compatibility.rst b/doc/release/upcoming_changes/23105.compatibility.rst
new file mode 100644
index 000000000..8a0b677e5
--- /dev/null
+++ b/doc/release/upcoming_changes/23105.compatibility.rst
@@ -0,0 +1,5 @@
+* When loading data from a file handle using ``np.load``,
+ if the handle is at the end of file, as can happen when reading
+ multiple arrays by calling ``np.load`` repeatedly, numpy previously
+ raised ``ValueError`` if ``allow_pickle=False``, and ``OSError`` if
+ ``allow_pickle=True``. Now it raises ``EOFError`` instead, in both cases.