From 1cfb32312a4643ee64f9d84ce4a064e3c4d6c217 Mon Sep 17 00:00:00 2001 From: Marcel Plch Date: Mon, 28 May 2018 10:53:17 +0200 Subject: [PATCH 1/2] Fix test_bad_traverse. --- .../test_importlib/extension/test_loader.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Lib/test/test_importlib/extension/test_loader.py b/Lib/test/test_importlib/extension/test_loader.py index 57ba7083d37d380..e9e8c9cd0c151ca 100644 --- a/Lib/test/test_importlib/extension/test_loader.py +++ b/Lib/test/test_importlib/extension/test_loader.py @@ -275,13 +275,18 @@ def test_bad_traverse(self): (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)""" + # This try block will prevent exceptions from ending the + # process with non-zero status + 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: + pass""" assert_python_failure("-c", script) From 6c7bbe838d5da1da8ae0e5f8f24e99dd3a331811 Mon Sep 17 00:00:00 2001 From: Marcel Plch Date: Mon, 28 May 2018 13:26:20 +0200 Subject: [PATCH 2/2] Edit comment --- Lib/test/test_importlib/extension/test_loader.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_importlib/extension/test_loader.py b/Lib/test/test_importlib/extension/test_loader.py index e9e8c9cd0c151ca..9ad05fadef29112 100644 --- a/Lib/test/test_importlib/extension/test_loader.py +++ b/Lib/test/test_importlib/extension/test_loader.py @@ -275,8 +275,6 @@ def test_bad_traverse(self): (Multiphase initialization modules only) ''' script = """if True: - # This try block will prevent exceptions from ending the - # process with non-zero status try: from test import support import importlib.util as util @@ -286,6 +284,9 @@ def test_bad_traverse(self): 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)