mirror of https://github.com/python/cpython
Merge with cpython.
This commit is contained in:
commit
d88e5af061
|
@ -1804,11 +1804,13 @@ class TarFile(object):
|
||||||
fileobj = gzip.GzipFile(name, mode + "b", compresslevel, fileobj)
|
fileobj = gzip.GzipFile(name, mode + "b", compresslevel, fileobj)
|
||||||
t = cls.taropen(name, mode, fileobj, **kwargs)
|
t = cls.taropen(name, mode, fileobj, **kwargs)
|
||||||
except IOError:
|
except IOError:
|
||||||
if not extfileobj:
|
if not extfileobj and fileobj is not None:
|
||||||
fileobj.close()
|
fileobj.close()
|
||||||
|
if fileobj is None:
|
||||||
|
raise
|
||||||
raise ReadError("not a gzip file")
|
raise ReadError("not a gzip file")
|
||||||
except:
|
except:
|
||||||
if not extfileobj:
|
if not extfileobj and fileobj is not None:
|
||||||
fileobj.close()
|
fileobj.close()
|
||||||
raise
|
raise
|
||||||
t._extfileobj = extfileobj
|
t._extfileobj = extfileobj
|
||||||
|
|
|
@ -1682,6 +1682,14 @@ class LinkEmulationTest(ReadTest):
|
||||||
class GzipMiscReadTest(MiscReadTest):
|
class GzipMiscReadTest(MiscReadTest):
|
||||||
tarname = gzipname
|
tarname = gzipname
|
||||||
mode = "r:gz"
|
mode = "r:gz"
|
||||||
|
|
||||||
|
def test_non_existent_targz_file(self):
|
||||||
|
# Test for issue11513: prevent non-existent gzipped tarfiles raising
|
||||||
|
# multiple exceptions.
|
||||||
|
with self.assertRaisesRegex(IOError, "xxx") as ex:
|
||||||
|
tarfile.open("xxx", self.mode)
|
||||||
|
self.assertEqual(ex.exception.errno, errno.ENOENT)
|
||||||
|
|
||||||
class GzipUstarReadTest(UstarReadTest):
|
class GzipUstarReadTest(UstarReadTest):
|
||||||
tarname = gzipname
|
tarname = gzipname
|
||||||
mode = "r:gz"
|
mode = "r:gz"
|
||||||
|
|
|
@ -44,6 +44,9 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #11513: Fix exception handling ``tarfile.TarFile.gzopen()`` when
|
||||||
|
the file cannot be opened.
|
||||||
|
|
||||||
- Issue #12687: Fix a possible buffering bug when unpickling text mode
|
- Issue #12687: Fix a possible buffering bug when unpickling text mode
|
||||||
(protocol 0, mostly) pickles.
|
(protocol 0, mostly) pickles.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue