You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Change error message for a NULL thread state on the free-threaded build #127314
In the C API, this message tends to be shown if you call a function without an active thread state:
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)
While reviewing #125962, I noticed that users don't really understand the distinction between having a thread state and the GIL being acquired, so I would imagine that C API users might end up very confused as to why Python is telling them that they need the GIL while it's disabled. In fact, I sort of noticed this in passing when figuring out #123134--users erroneously seemed to think that on the free-threaded build, it was OK to call functions in a fresh thread without calling PyGILState_Ensure or something first.
I think this is sort of a documentation problem (we should try to do a better job of clarifying the difference between "GIL" and "thread state"), but changing this error on the free-threaded build is a good start.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Activity
gh-127314: Don't mention the GIL when calling without a thread state …
pythongh-127314: Don't mention the GIL when calling without a thread …