summaryrefslogtreecommitdiffstats
path: root/Lib/tarfile.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2011-08-13 09:48:12 (GMT)
committerGeorg Brandl <georg@python.org>2011-08-13 09:48:12 (GMT)
commit3abb372c810c13af4207124c175cfd0a842b5f56 (patch)
treeb3d6c6acdc04ae9fedc5cd2b9e9b4538763a6ed5 /Lib/tarfile.py
parent963e40256a7047c538eca88a792710c2d6d53ac5 (diff)
downloadcpython-3abb372c810c13af4207124c175cfd0a842b5f56.zip
cpython-3abb372c810c13af4207124c175cfd0a842b5f56.tar.gz
cpython-3abb372c810c13af4207124c175cfd0a842b5f56.tar.bz2
Fix #11513: wrong exception handling for the case that GzipFile itself raises an IOError.
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 63c7554..3d52a81 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