@@ -100,11 +100,18 @@ def test_no_FatalError_infinite_loop(self):
100
100
_rc , out , err = run_result
101
101
self .assertEqual (out , b'' )
102
102
# 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, "
113
+ "but it was called without an active thread state. "
114
+ "Are you trying to call the C API inside of a Py_BEGIN_ALLOW_THREADS block?" ).encode ()
108
115
self .assertTrue (err .rstrip ().startswith (msg ),
109
116
err )
110
117
0 commit comments