|
21 | 21 | from test.support import import_helper
|
22 | 22 | from test.support import threading_helper
|
23 | 23 | 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 |
25 | 25 | try:
|
26 | 26 | import _posixsubprocess
|
27 | 27 | except ImportError:
|
@@ -69,21 +69,17 @@ def test_instancemethod(self):
|
69 | 69 |
|
70 | 70 | @support.requires_subprocess()
|
71 | 71 | 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'') |
81 | 77 | # This used to cause an infinite loop.
|
82 | 78 | msg = ("Fatal Python error: PyThreadState_Get: "
|
83 | 79 | "the function must be called with the GIL held, "
|
84 | 80 | "after Python initialization and before Python finalization, "
|
85 | 81 | "but the GIL is released "
|
86 |
| - "(the current Python thread state is NULL)") |
| 82 | + "(the current Python thread state is NULL)").encode() |
87 | 83 | self.assertTrue(err.rstrip().startswith(msg),
|
88 | 84 | err)
|
89 | 85 |
|
|
0 commit comments