Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8317d51

Browse filesBrowse files
authored
pythonGh-68586: use run_python_until_end in test_capi (pythonGH-102729)
Co-authored-by: Aidin Gharibnavaz Automerge-Triggered-By: GH:kumaraditya303
1 parent 45b4b37 commit 8317d51
Copy full SHA for 8317d51

File tree

Expand file treeCollapse file tree

1 file changed

+7
-11
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-11
lines changed

‎Lib/test/test_capi/test_misc.py

Copy file name to clipboardExpand all lines: Lib/test/test_capi/test_misc.py
+7-11Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from test.support import import_helper
2222
from test.support import threading_helper
2323
from test.support import warnings_helper
24-
from test.support.script_helper import assert_python_failure, assert_python_ok
24+
from test.support.script_helper import assert_python_failure, assert_python_ok, run_python_until_end
2525
try:
2626
import _posixsubprocess
2727
except ImportError:
@@ -69,21 +69,17 @@ def test_instancemethod(self):
6969

7070
@support.requires_subprocess()
7171
def test_no_FatalError_infinite_loop(self):
72-
with support.SuppressCrashReport():
73-
p = subprocess.Popen([sys.executable, "-c",
74-
'import _testcapi;'
75-
'_testcapi.crash_no_current_thread()'],
76-
stdout=subprocess.PIPE,
77-
stderr=subprocess.PIPE,
78-
text=True)
79-
(out, err) = p.communicate()
80-
self.assertEqual(out, '')
72+
run_result, _cmd_line = run_python_until_end(
73+
'-c', 'import _testcapi; _testcapi.crash_no_current_thread()',
74+
)
75+
_rc, out, err = run_result
76+
self.assertEqual(out, b'')
8177
# This used to cause an infinite loop.
8278
msg = ("Fatal Python error: PyThreadState_Get: "
8379
"the function must be called with the GIL held, "
8480
"after Python initialization and before Python finalization, "
8581
"but the GIL is released "
86-
"(the current Python thread state is NULL)")
82+
"(the current Python thread state is NULL)").encode()
8783
self.assertTrue(err.rstrip().startswith(msg),
8884
err)
8985

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.