summaryrefslogtreecommitdiff
path: root/Lib/test
diff options
context:
space:
mode:
authorIrit Katriel <iritkatriel@yahoo.com>2020-12-19 00:09:54 +0000
committerGitHub <noreply@github.com>2020-12-18 16:09:54 -0800
commitfb34096140bbb74c81500dd8bbc3c69c1d24d9ab (patch)
tree0b3dd85011b4d6f36068f0e69f38666178a10b48 /Lib/test
parente8d22642105d57007ab1242848a8cbadc7f179df (diff)
downloadcpython-git-fb34096140bbb74c81500dd8bbc3c69c1d24d9ab.tar.gz
bpo-24792: Fix zipimporter masking the cause of import errors (GH-22204)
zipimport's _unmarshal_code swallows import errors and then _get_module_code doesn't know the cause of the error, and returns the generic, and sometimes incorrect, 'could not find...'. Automerge-Triggered-By: GH:brettcannon
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_zipimport.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/test/test_zipimport.py b/Lib/test/test_zipimport.py
index 6dea2b1628..d59ef1ed6f 100644
--- a/Lib/test/test_zipimport.py
+++ b/Lib/test/test_zipimport.py
@@ -242,10 +242,10 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
files = {TESTMOD + pyc_ext: (NOW, badmagic_pyc)}
try:
self.doTest(".py", files, TESTMOD)
- except ImportError:
- pass
- else:
- self.fail("expected ImportError; import from bad pyc")
+ self.fail("This should not be reached")
+ except zipimport.ZipImportError as exc:
+ self.assertIsInstance(exc.__cause__, ImportError)
+ self.assertIn("magic number", exc.__cause__.msg)
def testBadMTime(self):
badtime_pyc = bytearray(test_pyc)