Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.4k
gh-108867: Add PyThreadState_GetUnchecked() function#108870
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
c180b5b
to572f4a4
CompareI was worried about /* Python 3.9 private API, invoked by the macros below. */PyAPI_FUNC(int)_PyTrash_begin(PyThreadState*tstate,PyObject*op);PyAPI_FUNC(void)_PyTrash_end(PyThreadState*tstate);/* Python 3.10 private API, invoked by the Py_TRASHCAN_BEGIN(). */PyAPI_FUNC(int)_PyTrash_cond(PyObject*op,destructordealloc); I was worried that we still provide Python 3.9 functions. Is it the a stable ABI? Nope, these functions are not part of Moreover, I explicitly removed the following macros from the limited C API in Python 3.9:
So in fact, we keep Python 3.9 functions for the ABI backward compatibility, whereas we donot support these APIs in the stable ABI. In short, it's ok to rename |
A bunch of projects currently uses Affected projects (18):
In this list, IMO the interesting one is Cython: $gitgrep-E'(_PyThreadState_UncheckedGet|__Pyx_PyThreadState_Current)'Cython/Utility/AsyncGen.c:tstate=__Pyx_PyThreadState_Current;Cython/Utility/AsyncGen.c:tstate=__Pyx_PyThreadState_Current;Cython/Utility/Coroutine.c:__Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current,pvalue)Cython/Utility/Coroutine.c:tstate=__Pyx_PyThreadState_Current;Cython/Utility/Coroutine.c:__Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current,&val);Cython/Utility/Exceptions.c:__pyx_assertions_enabled_flag= !_PyInterpreterState_GetConfig(__Pyx_PyThreadState_Current->interp)->optimization_level;Cython/Utility/Exceptions.c:#define__Pyx_PyThreadState_assign $local_tstate_cname = __Pyx_PyThreadState_Current;Cython/Utility/Exceptions.c:PyThreadState*tstate=__Pyx_PyThreadState_Current;Cython/Utility/Exceptions.c: (void)__Pyx_CLineForTraceback(__Pyx_PyThreadState_Current,c_line);Cython/Utility/Exceptions.c:PyThreadState*tstate=__Pyx_PyThreadState_Current;Cython/Utility/ModuleSetupCode.c:// Py3<3.5.2 does not support _PyThreadState_UncheckedGet().Cython/Utility/ModuleSetupCode.c:#define__Pyx_PyThreadState_Current PyThreadState_Get()Cython/Utility/ModuleSetupCode.c:#define__Pyx_PyThreadState_Current PyThreadState_GET()Cython/Utility/ModuleSetupCode.c:#define__Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()Cython/Utility/ModuleSetupCode.c:#define__Pyx_PyThreadState_Current PyThreadState_GET()Cython/Utility/ModuleSetupCode.c:#define__Pyx_PyThreadState_Current _PyThreadState_CurrentCython/Utility/ModuleSetupCode.c:current=tcur==__Pyx_PyThreadState_Current;Cython/Utility/ObjectHandling.c:PyThreadState*tstate=__Pyx_PyThreadState_Current;Cython/Utility/Profile.c:tstate=__Pyx_PyThreadState_Current; \Cython/Utility/Profile.c:PyThreadState*tstate=__Pyx_PyThreadState_Current; \Cython/Utility/Profile.c:tstate=__Pyx_PyThreadState_Current; \Cython/Utility/Profile.c:PyThreadState*tstate=__Pyx_PyThreadState_Current; \Cython/Utility/Profile.c:PyThreadState*tstate=__Pyx_PyThreadState_Current; \Cython/Utility/Profile.c:tstate=__Pyx_PyThreadState_Current; \Cython/Utility/Profile.c:PyThreadState*tstate=__Pyx_PyThreadState_Current; \Cython/Utility/Profile.c:PyThreadState*tstate=__Pyx_PyThreadState_Current; \ I can easily add PyThreadState_GetUnsafe() topythoncapi-compat by calling
|
Iasked in the C API Working Group which function name is better: useUnchecked suffix orUnsafe suffix? |
Uh oh!
There was an error while loading.Please reload this page.
I renamed the function to PyThreadState_GetUnchecked() and addressed@encukou's suggestion on the documentation. |
Uh oh!
There was an error while loading.Please reload this page.
Add PyThreadState_GetUnchecked() function: similar toPyThreadState_Get(), but don't issue a fatal error if it is NULL. Thecaller is responsible to check if the result is NULL. Previously,this function was private and known as _PyThreadState_UncheckedGet().
Oops, my PR still used PyThreadState_GetUnsafe() name. I messed up something. Anyway, I updated it again, and now it uses PyThreadState_GetUnchecked() name everywhere. |
I added PyThreadState_GetUnchecked() to pythoncapi-compat:python/pythoncapi-compat@f78c780 |
…8870)Add PyThreadState_GetUnchecked() function: similar toPyThreadState_Get(), but don't issue a fatal error if it is NULL. Thecaller is responsible to check if the result is NULL. Previously,this function was private and known as _PyThreadState_UncheckedGet().
Uh oh!
There was an error while loading.Please reload this page.
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().
📚 Documentation preview 📚:https://cpython-previews--108870.org.readthedocs.build/