summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_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/test/test_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/test/test_tarfile.py')
-rw-r--r--Lib/test/test_tarfile.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
index 8036c5c..b45f168 100644
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -1682,6 +1682,14 @@ class LinkEmulationTest(ReadTest):
class GzipMiscReadTest(MiscReadTest):
tarname = gzipname
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):
tarname = gzipname
mode = "r:gz"