Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C API: Rename _PyThreadState_GetUnchecked() to public PyThreadState_GetUnchecked #108867

Closed
vstinner opened this issue Sep 4, 2023 · 1 comment

Comments

@vstinner
Copy link
Member

vstinner commented Sep 4, 2023

The _PyThreadState_UncheckedGet() function was added in Python 3.5 (2016) by issue #70342 with commit bfd316e. I was asked by PyPy developers to have an API to get the current thread state, but don't call Py_FatalError() if it's NULL. See: https://mail.python.org/pipermail/python-dev/2016-January/142767.html

In Python 3.13, I'm trying to remove private functions from the public C API: issue #106320.

Since _PyThreadState_UncheckedGet() had at least one user and exposing this API is revelant, I propose renaming the private _PyThreadState_UncheckedGet() function to PyThreadState_GetUnchecked() and so make it public, but not added it to the limited C API (not needed).

For the function name, see: capi-workgroup/problems#52 I propose to use the Unsafe suffix for "unsafe" function. Previously, the function used Unchecked, but it wasn't a suffix!

UPDATE: I renamed PyThreadState_GetUnsafe() to PyThreadState_GetUnchecked().

Linked PRs

vstinner added a commit to vstinner/cpython that referenced this issue Sep 4, 2023
Add PyThreadState_GetUnsafe() function: similar to
PyThreadState_Get(), but don't issue a fatal error if it is NULL. The
caller is responsible to check if the result is NULL. Previously,
this function was private and known as _PyThreadState_UncheckedGet().
vstinner added a commit to vstinner/cpython that referenced this issue Sep 6, 2023
Add PyThreadState_GetUnsafe() function: similar to
PyThreadState_Get(), but don't issue a fatal error if it is NULL. The
caller is responsible to check if the result is NULL. Previously,
this function was private and known as _PyThreadState_UncheckedGet().
vstinner added a commit to vstinner/cpython that referenced this issue Sep 6, 2023
Add PyThreadState_GetUnsafe() function: similar to
PyThreadState_Get(), but don't issue a fatal error if it is NULL. The
caller is responsible to check if the result is NULL. Previously,
this function was private and known as _PyThreadState_UncheckedGet().
@vstinner vstinner changed the title C API: Rename _PyThreadState_UncheckedGet() to public PyThreadState_GetUnsafe() C API: Rename _PyThreadState_GetUnchecked() to public PyThreadState_GetUnsafe() Sep 12, 2023
vstinner added a commit to vstinner/cpython that referenced this issue Oct 3, 2023
Add PyThreadState_GetUnsafe() function: similar to
PyThreadState_Get(), but don't issue a fatal error if it is NULL. The
caller is responsible to check if the result is NULL. Previously,
this function was private and known as _PyThreadState_UncheckedGet().
@vstinner vstinner changed the title C API: Rename _PyThreadState_GetUnchecked() to public PyThreadState_GetUnsafe() C API: Rename _PyThreadState_GetUnchecked() to public PyThreadState_GetUnchecked Oct 3, 2023
vstinner added a commit to vstinner/cpython that referenced this issue Oct 3, 2023
Add PyThreadState_GetUnchecked() function: similar to
PyThreadState_Get(), but don't issue a fatal error if it is NULL. The
caller is responsible to check if the result is NULL. Previously,
this function was private and known as _PyThreadState_UncheckedGet().
@vstinner
Copy link
Member Author

vstinner commented Oct 3, 2023

UPDATE: I renamed PyThreadState_GetUnsafe() to PyThreadState_GetUnchecked().

vstinner added a commit that referenced this issue Oct 3, 2023
Add PyThreadState_GetUnchecked() function: similar to
PyThreadState_Get(), but don't issue a fatal error if it is NULL. The
caller is responsible to check if the result is NULL. Previously,
this function was private and known as _PyThreadState_UncheckedGet().
@vstinner vstinner closed this as completed Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant