@@ -100,11 +100,17 @@ def test_no_FatalError_infinite_loop(self):
100100 _rc , out , err = run_result
101101 self .assertEqual (out , b'' )
102102 # This used to cause an infinite loop.
103- msg = ("Fatal Python error: PyThreadState_Get: "
104- "the function must be called with the GIL held, "
105- "after Python initialization and before Python finalization, "
106- "but the GIL is released "
107- "(the current Python thread state is NULL)" ).encode ()
103+ if not support .Py_GIL_DISABLED :
104+ msg = ("Fatal Python error: PyThreadState_Get: "
105+ "the function must be called with the GIL held, "
106+ "after Python initialization and before Python finalization, "
107+ "but the GIL is released "
108+ "(the current Python thread state is NULL)" ).encode ()
109+ else :
110+ msg = ("Fatal Python error: PyThreadState_Get: "
111+ "the function must be called with an active thread state, "
112+ "after Python initialization and before Python finalization, but it is NULL "
113+ "(are you trying to call the C API inside of a Py_BEGIN_ALLOW_THREADS block?)" ).encode ()
108114 self .assertTrue (err .rstrip ().startswith (msg ),
109115 err )
110116
0 commit comments