diff options
author | Pauli Virtanen <pav@iki.fi> | 2010-10-10 23:31:22 +0200 |
---|---|---|
committer | Pauli Virtanen <pav@iki.fi> | 2010-10-10 23:32:12 +0200 |
commit | 68e31fe815e0cb6276970a1c365f21e187d10ca0 (patch) | |
tree | 2c2bcb34ad0c06a2d25b1c4c5808439656bda639 /numpy/lib/npyio.py | |
parent | 61d14a1489714890bbcf0afad3665f4af47e133d (diff) | |
download | numpy-68e31fe815e0cb6276970a1c365f21e187d10ca0.tar.gz |
ENH: lib: allow zip64 extensions in .npz files; allows > 2GB
Diffstat (limited to 'numpy/lib/npyio.py')
-rw-r--r-- | numpy/lib/npyio.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index 2e6b5e793..2668357bc 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -108,7 +108,11 @@ class BagObj(object): except KeyError: raise AttributeError, key - +def zipfile_factory(*args, **kwargs): + import zipfile + if sys.version_info >= (2, 5): + kwargs['allowZip64'] = True + return zipfile.ZipFile(*args, **kwargs) class NpzFile(object): """ @@ -169,8 +173,7 @@ class NpzFile(object): def __init__(self, fid, own_fid=False): # Import is postponed to here since zipfile depends on gzip, an optional # component of the so-called standard library. - import zipfile - _zip = zipfile.ZipFile(fid) + _zip = zipfile_factory(fid) self._files = _zip.namelist() self.files = [] for x in self._files: @@ -528,7 +531,7 @@ def _savez(file, args, kwds, compress): else: compression = zipfile.ZIP_STORED - zip = zipfile.ZipFile(file, mode="w", compression=compression) + zip = zipfile_factory(file, mode="w", compression=compression) # Stage arrays in a temporary file on disk, before writing to zip. fd, tmpfile = tempfile.mkstemp(suffix='-numpy.npy') |