Skip to content

Commit 4a1026d

Browse files
authored
gh-106714: Fix test_capi to not write a coredump (#107007)
test_capi: Fix test_no_FatalError_infinite_loop() to no longer write a coredump, by using test.support.SuppressCrashReport.
1 parent 6dbffae commit 4a1026d

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

Lib/test/test_capi/test_misc.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,15 @@ def test_instancemethod(self):
8585

8686
@support.requires_subprocess()
8787
def test_no_FatalError_infinite_loop(self):
88-
run_result, _cmd_line = run_python_until_end(
89-
'-c', 'import _testcapi; _testcapi.crash_no_current_thread()',
90-
)
88+
code = textwrap.dedent("""
89+
import _testcapi
90+
from test import support
91+
92+
with support.SuppressCrashReport():
93+
_testcapi.crash_no_current_thread()
94+
""")
95+
96+
run_result, _cmd_line = run_python_until_end('-c', code)
9197
_rc, out, err = run_result
9298
self.assertEqual(out, b'')
9399
# This used to cause an infinite loop.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
test_capi: Fix test_no_FatalError_infinite_loop() to no longer write a
2+
coredump, by using test.support.SuppressCrashReport. Patch by Victor
3+
Stinner.

0 commit comments

Comments
 (0)