[Python-checkins] [3.12] gh-106714: Fix test_capi to not write a coredump (GH-107007) (#107009)

vstinner webhook-mailer at python.org
Sat Jul 22 08:48:45 EDT 2023


https://github.com/python/cpython/commit/713590f9b2bef0641511b5195bdbb4c9253e9b8c
commit: 713590f9b2bef0641511b5195bdbb4c9253e9b8c
branch: 3.12
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: vstinner <vstinner at python.org>
date: 2023-07-22T12:48:41Z
summary:

[3.12] gh-106714: Fix test_capi to not write a coredump (GH-107007) (#107009)

gh-106714: Fix test_capi to not write a coredump (GH-107007)

test_capi: Fix test_no_FatalError_infinite_loop() to no longer write
a coredump, by using test.support.SuppressCrashReport.
(cherry picked from commit 4a1026d7647c084b0dc80dd49163d16ba12a2e55)

Co-authored-by: Victor Stinner <vstinner at python.org>

files:
A Misc/NEWS.d/next/Tests/2023-07-22-13-49-40.gh-issue-106714.btYI5S.rst
M Lib/test/test_capi/test_misc.py

diff --git a/Lib/test/test_capi/test_misc.py b/Lib/test/test_capi/test_misc.py
index 61947cb794519..cd37fc71aa966 100644
--- a/Lib/test/test_capi/test_misc.py
+++ b/Lib/test/test_capi/test_misc.py
@@ -85,9 +85,15 @@ def test_instancemethod(self):
 
     @support.requires_subprocess()
     def test_no_FatalError_infinite_loop(self):
-        run_result, _cmd_line = run_python_until_end(
-            '-c', 'import _testcapi; _testcapi.crash_no_current_thread()',
-        )
+        code = textwrap.dedent("""
+            import _testcapi
+            from test import support
+
+            with support.SuppressCrashReport():
+                _testcapi.crash_no_current_thread()
+        """)
+
+        run_result, _cmd_line = run_python_until_end('-c', code)
         _rc, out, err = run_result
         self.assertEqual(out, b'')
         # This used to cause an infinite loop.
diff --git a/Misc/NEWS.d/next/Tests/2023-07-22-13-49-40.gh-issue-106714.btYI5S.rst b/Misc/NEWS.d/next/Tests/2023-07-22-13-49-40.gh-issue-106714.btYI5S.rst
new file mode 100644
index 0000000000000..955620521c8f6
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2023-07-22-13-49-40.gh-issue-106714.btYI5S.rst
@@ -0,0 +1,3 @@
+test_capi: Fix test_no_FatalError_infinite_loop() to no longer write a
+coredump, by using test.support.SuppressCrashReport. Patch by Victor
+Stinner.



More information about the Python-checkins mailing list