summaryrefslogtreecommitdiff
path: root/numpy/lib/npyio.py
diff options
context:
space:
mode:
authorBartosz Telenczuk <muchatel@poczta.fm>2013-01-22 13:45:37 +0100
committerBartosz Telenczuk <muchatel@poczta.fm>2013-06-12 13:34:28 +0200
commitcfae0143b436c3296eebe71e2dd730625dcaae95 (patch)
treec4f9999bc0c073fc3c87d9a89d02a39ca694ec48 /numpy/lib/npyio.py
parentd4b4ff038d536500e4bfd16f164d88a1a99f5ac3 (diff)
downloadnumpy-cfae0143b436c3296eebe71e2dd730625dcaae95.tar.gz
BUG: fix loading large npz files (fixes #2922)
Diffstat (limited to 'numpy/lib/npyio.py')
-rw-r--r--numpy/lib/npyio.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py
index fbcb5a46e..d400b4d30 100644
--- a/numpy/lib/npyio.py
+++ b/numpy/lib/npyio.py
@@ -244,12 +244,14 @@ class NpzFile(object):
member = 1
key += '.npy'
if member:
- bytes = self.zip.read(key)
- if bytes.startswith(format.MAGIC_PREFIX):
- value = BytesIO(bytes)
- return format.read_array(value)
+ bytes = self.zip.open(key)
+ magic = bytes.read(len(format.MAGIC_PREFIX))
+ bytes.close()
+ if magic == format.MAGIC_PREFIX:
+ bytes = self.zip.open(key)
+ return format.read_array(bytes)
else:
- return bytes
+ return self.zip.read(key)
else:
raise KeyError("%s is not a file in the archive" % key)