diff options
author | Stefan van der Walt <stefan@sun.ac.za> | 2010-11-23 23:22:47 +0200 |
---|---|---|
committer | Stefan van der Walt <stefan@sun.ac.za> | 2010-11-23 23:22:47 +0200 |
commit | 8fa2591fee88937b81c39a6c529fa66975f88856 (patch) | |
tree | 9157f3c232ba30a4de7c6f160151b96ead2c6e79 /numpy/lib/npyio.py | |
parent | 0131218566f5daf215dab7bf5b46705145ac87c6 (diff) | |
download | numpy-8fa2591fee88937b81c39a6c529fa66975f88856.tar.gz |
BUG: Fix GzipFile wrapper to be <= 2.5 compatible.
Diffstat (limited to 'numpy/lib/npyio.py')
-rw-r--r-- | numpy/lib/npyio.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index 4a56a6ecc..aeccc2a24 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -62,11 +62,16 @@ def seek_gzip_factory(f): f = GzipFile(f) elif isinstance(f, gzip.GzipFile): # cast to our GzipFile if its already a gzip.GzipFile - g = GzipFile(fileobj=f.fileobj) - g.name = f.name - g.mode = f.mode - f = g + try: + name = f.name + except AttributeError: + # Backward compatibility for <= 2.5 + name = f.filename + mode = f.mode + + f = GzipFile(fileobj=f.fileobj, filename=name) + f.mode = mode return f |