Fix #11513: wrong exception handling for the case that GzipFile itself raises an IOError.

This commit is contained in:
Georg Brandl 2011-08-13 11:48:12 +02:00
parent 963e40256a
commit 3abb372c81
3 changed files with 15 additions and 2 deletions

View file

@ -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