mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
gh-127314: Don't mention the GIL when calling without a thread state on the free-threaded build (#127315)
Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
parent
a353455fca
commit
12680ec5bd
5 changed files with 36 additions and 7 deletions
|
@ -190,10 +190,18 @@ static inline void
|
|||
_Py_EnsureFuncTstateNotNULL(const char *func, PyThreadState *tstate)
|
||||
{
|
||||
if (tstate == NULL) {
|
||||
#ifndef Py_GIL_DISABLED
|
||||
_Py_FatalErrorFunc(func,
|
||||
"the function must be called with the GIL held, "
|
||||
"after Python initialization and before Python finalization, "
|
||||
"but the GIL is released (the current Python thread state is NULL)");
|
||||
#else
|
||||
_Py_FatalErrorFunc(func,
|
||||
"the function must be called with an active thread state, "
|
||||
"after Python initialization and before Python finalization, "
|
||||
"but it was called without an active thread state. "
|
||||
"Are you trying to call the C API inside of a Py_BEGIN_ALLOW_THREADS block?");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue