Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ Python 3.13

See `PyObject_ClearManagedDict() documentation <https://docs.python.org/dev/c-api/object.html#c.PyObject_ClearManagedDict>`__.

.. c:function:: PyThreadState* PyThreadState_GetUnchecked(void)

See `PyThreadState_GetUnchecked() documentation <https://docs.python.org/dev/c-api/init.html#c.PyThreadState_GetUnchecked>`__.

Available on Python 3.5.2 and newer.


Python 3.12
-----------
Expand Down
8 changes: 6 additions & 2 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -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()``
Expand Down
10 changes: 10 additions & 0 deletions pythoncapi_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 5 additions & 0 deletions tests/test_pythoncapi_compat_cext.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down