summaryrefslogtreecommitdiff
path: root/Lib/tarfile.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2011-08-13 11:54:33 +0200
committerGeorg Brandl <georg@python.org>2011-08-13 11:54:33 +0200
commitd88e5af061c4c3206699fe7b86e736c42fdeba1c (patch)
tree8f1ac2f3c1df785a6a327f19433067d57f507277 /Lib/tarfile.py
parentb3f0ce4d1ea6a48774af22e20b8f748c19f87462 (diff)
parent3abb372c810c13af4207124c175cfd0a842b5f56 (diff)
downloadcpython-git-d88e5af061c4c3206699fe7b86e736c42fdeba1c.tar.gz
Merge with cpython.
Diffstat (limited to 'Lib/tarfile.py')
-rw-r--r--Lib/tarfile.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index 63c7554af2..3d52a81b9e 100644
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -1804,11 +1804,13 @@ class TarFile(object):
fileobj = gzip.GzipFile(name, mode + "b", compresslevel, fileobj)
t = cls.taropen(name, mode, fileobj, **kwargs)
except IOError:
- if not extfileobj:
+ if not extfileobj and fileobj is not None:
fileobj.close()
+ if fileobj is None:
+ raise
raise ReadError("not a gzip file")
except:
- if not extfileobj:
+ if not extfileobj and fileobj is not None:
fileobj.close()
raise
t._extfileobj = extfileobj