diff options
author | Erik M. Bray <erik.bray@lri.fr> | 2016-05-06 13:21:53 +0200 |
---|---|---|
committer | Erik M. Bray <erik.bray@lri.fr> | 2016-05-31 16:33:30 +0200 |
commit | ee02cdda6c8d135098baa1d5afe41fd4996d587c (patch) | |
tree | cf5c999ae5517ea225831e12602c8448b6476453 /numpy/lib/npyio.py | |
parent | db7c0b74d3d85521769042ff91309baeb57aae0d (diff) | |
download | numpy-ee02cdda6c8d135098baa1d5afe41fd4996d587c.tar.gz |
BUG: Fixes to reading and writing of empty arrays, and in particular arrays with empty dtypes. See #6430
Diffstat (limited to 'numpy/lib/npyio.py')
-rw-r--r-- | numpy/lib/npyio.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index 4b6770483..179dbd8da 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -399,7 +399,9 @@ def load(file, mmap_mode=None, allow_pickle=True, fix_imports=True, _ZIP_PREFIX = asbytes('PK\x03\x04') N = len(format.MAGIC_PREFIX) magic = fid.read(N) - fid.seek(-N, 1) # back-up + # If the file size is less than N, we need to make sure not + # to seek past the beginning of the file + fid.seek(-min(N, len(magic)), 1) # back-up if magic.startswith(_ZIP_PREFIX): # zip-file (assume .npz) # Transfer file ownership to NpzFile |