summaryrefslogtreecommitdiffstats
path: root/Include/internal
diff options
context:
space:
mode:
authorPeter Bierma <zintensitydev@gmail.com>2024-12-06 15:58:19 (GMT)
committerGitHub <noreply@github.com>2024-12-06 15:58:19 (GMT)
commit12680ec5bd45c85b6daebe0739d30ef45f089efa (patch)
treea94a35fc4e7fbb5daf875c5142d50a89e595d957 /Include/internal
parenta353455fca1b8f468ff3ffbb4b5e316510b4fd43 (diff)
downloadcpython-12680ec5bd45c85b6daebe0739d30ef45f089efa.zip
cpython-12680ec5bd45c85b6daebe0739d30ef45f089efa.tar.gz
cpython-12680ec5bd45c85b6daebe0739d30ef45f089efa.tar.bz2
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>
Diffstat (limited to 'Include/internal')
-rw-r--r--Include/internal/pycore_pystate.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/Include/internal/pycore_pystate.h b/Include/internal/pycore_pystate.h
index 54d8803..1e73e54 100644
--- a/Include/internal/pycore_pystate.h
+++ b/Include/internal/pycore_pystate.h
@@ -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
}
}