diff options
author | Victor Stinner <vstinner@python.org> | 2023-10-03 16:53:51 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-03 16:53:51 (GMT) |
commit | d73501602f863a54c872ce103cd3fa119e38bac9 (patch) | |
tree | df6d23aa36d385215bb03f22fe0aacf625bbdf1e /Doc | |
parent | 6ab6040054e5ca2d3eb7833dc8bf4eb0bbaa0aac (diff) | |
download | cpython-d73501602f863a54c872ce103cd3fa119e38bac9.zip cpython-d73501602f863a54c872ce103cd3fa119e38bac9.tar.gz cpython-d73501602f863a54c872ce103cd3fa119e38bac9.tar.bz2 |
gh-108867: Add PyThreadState_GetUnchecked() function (#108870)
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().
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/c-api/init.rst | 13 | ||||
-rw-r--r-- | Doc/whatsnew/3.13.rst | 7 |
2 files changed, 20 insertions, 0 deletions
diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst index 60f5c81..d164d1a 100644 --- a/Doc/c-api/init.rst +++ b/Doc/c-api/init.rst @@ -870,6 +870,19 @@ code, or when embedding the Python interpreter: When the current thread state is ``NULL``, this issues a fatal error (so that the caller needn't check for ``NULL``). + See also :c:func:`PyThreadState_GetUnchecked`. + + +.. c:function:: PyThreadState* PyThreadState_GetUnchecked() + + Similar to :c:func:`PyThreadState_Get`, but don't kill the process with a + fatal error if it is NULL. The caller is responsible to check if the result + is NULL. + + .. versionadded:: 3.13 + In Python 3.5 to 3.12, the function was private and known as + ``_PyThreadState_UncheckedGet()``. + .. c:function:: PyThreadState* PyThreadState_Swap(PyThreadState *tstate) diff --git a/Doc/whatsnew/3.13.rst b/Doc/whatsnew/3.13.rst index a99d114..785deea 100644 --- a/Doc/whatsnew/3.13.rst +++ b/Doc/whatsnew/3.13.rst @@ -1003,6 +1003,13 @@ New Features functions on Python 3.11 and 3.12. (Contributed by Victor Stinner in :gh:`107073`.) +* Add :c:func:`PyThreadState_GetUnchecked()` function: similar to + :c:func:`PyThreadState_Get()`, but don't kill the process with a fatal error + if it is NULL. The caller is responsible to check if the result is NULL. + Previously, the function was private and known as + ``_PyThreadState_UncheckedGet()``. + (Contributed by Victor Stinner in :gh:`108867`.) + Porting to Python 3.13 ---------------------- |