bpo-32374: Ignore Python-level exceptions in test_bad_traverse (GH-7145) · python/cpython@08c5aca

File tree

1 file changed

lines changed

  • Lib/test/test_importlib/extension

1 file changed

lines changed

Original file line numberDiff line numberDiff line change

@@ -275,13 +275,19 @@ def test_bad_traverse(self):

275275

(Multiphase initialization modules only)

276276

'''

277277

script = """if True:

278-

from test import support

279-

import importlib.util as util

280-

spec = util.find_spec('_testmultiphase')

281-

spec.name = '_testmultiphase_with_bad_traverse'

282-
283-

with support.SuppressCrashReport():

284-

m = spec.loader.create_module(spec)"""

278+

try:

279+

from test import support

280+

import importlib.util as util

281+

spec = util.find_spec('_testmultiphase')

282+

spec.name = '_testmultiphase_with_bad_traverse'

283+
284+

with support.SuppressCrashReport():

285+

m = spec.loader.create_module(spec)

286+

except:

287+

# Prevent Python-level exceptions from

288+

# ending the process with non-zero status

289+

# (We are testing for a crash in C-code)

290+

pass"""

285291

assert_python_failure("-c", script)

286292
287293