Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Deprecate and Then Remove PyGILState_GetThisThreadState() #131265

Copy link
Copy link
Open
@ericsnowcurrently

Description

@ericsnowcurrently
Issue body actions

Feature or enhancement

Proposal:

(See https://docs.python.org/3/c-api/init.html#c.PyGILState_GetThisThreadState.)

PyGILState_GetThisThreadState() was added as part of the PEP 311 implementation. However, it wasn't part of that proposal. It isn't clear that it was even meant to be public API.

If a user wants to know what the current thread state is then they should use PyThreadState_Get(). PyGILState_GetThisThreadState() is subtly different and surfaces some of the tricky PyGILState corner cases that PyThreadState_Get() blissfully ignores. A real issue here is that users are reasonably likely to stumble across PyGILState_GetThisThreadState() and, due to the name, use it instead of the proper API.

I can think of one thing that PyGILState_GetThisThreadState() does exclusively: it will tell you what existing thread state PyGILState_Ensure() will use, if any. It isn't clear to me if that's a meaningful use case.

Ultimately, I expect we would be fine to get rid of PyGILState_GetThisThreadState(). If still useful for core development, it could be moved to the internal C-API.

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.