diff --git a/docs/api.rst b/docs/api.rst index c2564f5..9204d9a 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -107,6 +107,12 @@ Python 3.13 See `PyObject_ClearManagedDict() documentation `__. +.. c:function:: PyThreadState* PyThreadState_GetUnchecked(void) + + See `PyThreadState_GetUnchecked() documentation `__. + + Available on Python 3.5.2 and newer. + Python 3.12 ----------- diff --git a/docs/changelog.rst b/docs/changelog.rst index b5203b8..9fd3d06 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,8 +1,12 @@ Changelog ========= -* 2023-10-03: Add ``PyObject_VisitManagedDict()`` and - ``PyObject_ClearManagedDict()`` functions. +* 2023-10-03: Add functions: + + * ``PyObject_VisitManagedDict()`` + * ``PyObject_ClearManagedDict()`` + * ``PyThreadState_GetUnchecked()`` + * 2023-09-29: Add functions: * ``PyMapping_HasKeyWithError()`` diff --git a/pythoncapi_compat.h b/pythoncapi_compat.h index fa32887..dcd97ff 100644 --- a/pythoncapi_compat.h +++ b/pythoncapi_compat.h @@ -929,6 +929,16 @@ PyObject_ClearManagedDict(PyObject *obj) } #endif +// gh-108867 added PyThreadState_GetUnchecked() to Python 3.13.0a1 +// Python 3.5.2 added _PyThreadState_UncheckedGet(). +#if PY_VERSION_HEX >= 0x03050200 && PY_VERSION_HEX < 0x030D00A1 +static inline PyThreadState* +PyThreadState_GetUnchecked(void) +{ + return _PyThreadState_UncheckedGet(); +} +#endif + #ifdef __cplusplus } diff --git a/tests/test_pythoncapi_compat_cext.c b/tests/test_pythoncapi_compat_cext.c index b50333d..78ee1c8 100644 --- a/tests/test_pythoncapi_compat_cext.c +++ b/tests/test_pythoncapi_compat_cext.c @@ -318,6 +318,11 @@ test_thread_state(PyObject *Py_UNUSED(module), PyObject* Py_UNUSED(ignored)) PyThreadState_LeaveTracing(tstate); #endif +#if PY_VERSION_HEX >= 0x03050200 + // PyThreadState_GetUnchecked() + assert(PyThreadState_GetUnchecked() == tstate); +#endif + Py_RETURN_NONE; } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy