]> granicus.if.org Git - python/commitdiff
bpo-32374: Ignore Python-level exceptions in test_bad_traverse (GH-7145)
authorMarcel Plch <gmarcel.plch@gmail.com>
Mon, 28 May 2018 12:11:20 +0000 (14:11 +0200)
committerPetr Viktorin <encukou@gmail.com>
Mon, 28 May 2018 12:11:20 +0000 (14:11 +0200)
Lib/test/test_importlib/extension/test_loader.py

index 57ba7083d37d3801caec961946c821bab1203570..9ad05fadef29112e56d68095f516a969d2e22e1d 100644 (file)
@@ -275,13 +275,19 @@ class MultiPhaseExtensionModuleTests(abc.LoaderTests):
             (Multiphase initialization modules only)
         '''
         script = """if True:
-                from test import support
-                import importlib.util as util
-                spec = util.find_spec('_testmultiphase')
-                spec.name = '_testmultiphase_with_bad_traverse'
-
-                with support.SuppressCrashReport():
-                    m = spec.loader.create_module(spec)"""
+                try:
+                    from test import support
+                    import importlib.util as util
+                    spec = util.find_spec('_testmultiphase')
+                    spec.name = '_testmultiphase_with_bad_traverse'
+
+                    with support.SuppressCrashReport():
+                        m = spec.loader.create_module(spec)
+                except:
+                    # Prevent Python-level exceptions from
+                    # ending the process with non-zero status
+                    # (We are testing for a crash in C-code)
+                    pass"""
         assert_python_failure("-c", script)