summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_importlib
diff options
context:
space:
mode:
authorSebastian Berg <sebastianb@nvidia.com>2022-12-23 23:43:19 (GMT)
committerGitHub <noreply@github.com>2022-12-23 23:43:19 (GMT)
commit474220e3a58d739acc5154eb3e000461d2222d62 (patch)
tree2f26951f08993d62a28107b03b1191d6467fd23b /Lib/test/test_importlib
parenta68e585c8b7b27323f67905868467ce0588a1dae (diff)
downloadcpython-474220e3a58d739acc5154eb3e000461d2222d62.zip
cpython-474220e3a58d739acc5154eb3e000461d2222d62.tar.gz
cpython-474220e3a58d739acc5154eb3e000461d2222d62.tar.bz2
gh-99947: Ensure unreported errors are chained for SystemError during import (GH-99946)
Diffstat (limited to 'Lib/test/test_importlib')
-rw-r--r--Lib/test/test_importlib/extension/test_loader.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/test/test_importlib/extension/test_loader.py b/Lib/test/test_importlib/extension/test_loader.py
index d69192b..3bf2bbd 100644
--- a/Lib/test/test_importlib/extension/test_loader.py
+++ b/Lib/test/test_importlib/extension/test_loader.py
@@ -351,9 +351,14 @@ class MultiPhaseExtensionModuleTests(abc.LoaderTests):
]:
with self.subTest(name_base):
name = self.name + '_' + name_base
- with self.assertRaises(SystemError):
+ with self.assertRaises(SystemError) as cm:
self.load_module_by_name(name)
+ # If there is an unreported exception, it should be chained
+ # with the `SystemError`.
+ if "unreported_exception" in name_base:
+ self.assertIsNotNone(cm.exception.__cause__)
+
def test_nonascii(self):
# Test that modules with non-ASCII names can be loaded.
# punycode behaves slightly differently in some-ASCII and no-ASCII