From d804f53679cdbde546dc2ae49aecd12c4ea944a5 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 13 Jan 2014 19:08:51 +0200 Subject: [PATCH] Backported test for the open of non-existent tarfile. --- Lib/test/test_tarfile.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py index d3ad707e82..3e054ac5ee 100644 --- a/Lib/test/test_tarfile.py +++ b/Lib/test/test_tarfile.py @@ -181,6 +181,14 @@ class CommonReadTest(ReadTest): self.assertRaises(tarfile.ReadError, tarfile.open, tmpname, self.mode) self.assertRaises(tarfile.ReadError, tarfile.open, tmpname) + def test_non_existent_tarfile(self): + # Test for issue11513: prevent non-existent gzipped tarfiles raising + # multiple exceptions. + exctype = OSError if '|' in self.mode else IOError + with self.assertRaisesRegexp(exctype, "xxx") as ex: + tarfile.open("xxx", self.mode) + self.assertEqual(ex.exception.errno, errno.ENOENT) + def test_ignore_zeros(self): # Test TarFile's ignore_zeros option. if self.mode.endswith(":gz"): -- 2.50.1