GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||
GeezerVison is showing github.com — gh-108867: Add PyThreadState_GetUnchecked() function by vstinner · Pull Request #108870 · python/cpython Conversation
|
|
I 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, destructor dealloc); 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 do not support these APIs in the stable ABI. In short, it's ok to rename |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
A bunch of projects currently uses Affected projects (18):
In this list, IMO the interesting one is Cython: $ git grep -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_Current Cython/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() to pythoncapi-compat by calling |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I asked in the C API Working Group which function name is better: use Unchecked suffix or Unsafe suffix? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
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. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
cddb3cc to
92b23e7
Compare
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().
92b23e7 to
2372091
Compare
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. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I added PyThreadState_GetUnchecked() to pythoncapi-compat: python/pythoncapi-compat@f78c780 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…8870) 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().
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.