Skip to content

PyThreadState_DeleteCurrent documentation incorrect #115145

Closed
@colesbury

Description

@colesbury

The documentation for PyThreadState_DeleteCurrent() says:

Destroy the current thread state and release the global interpreter lock. Like PyThreadState_Delete(), the global interpreter lock need not be held. The thread state must have been reset with a previous call to PyThreadState_Clear().

However, calling the function without holding the GIL results in a fatal Python error:

Fatal Python error: _PyThreadState_DeleteCurrent: 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)

It looks to me like like CPython code since at least 3.8 required holding the GIL when calling PyThreadState_DeleteCurrent(), so I think we should update the documentation rather than change the implementation.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions