Skip to content

Commit

Permalink
BUG: Fix GzipFile wrapper to be <= 2.5 compatible.
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanv committed Nov 23, 2010
1 parent 0131218 commit 8fa2591
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions numpy/lib/npyio.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,16 @@ def tell(self):
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

Expand Down

0 comments on commit 8fa2591

Please sign in to comment.