Skip to content

Commit 4e1d6d2

Browse files
committed
PyUnstable_SetImmortal() is not available on the limited C API
1 parent c31d187 commit 4e1d6d2

3 files changed

Lines changed: 6 additions & 1 deletion

File tree

‎docs/api.rst‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,8 @@ Python 3.14
349349

350350
Not available on PyPy. ``Py_REFCNT()`` semantics is different on PyPy.
351351

352+
Not available on the limited C API.
353+
352354
.. c:function:: void PyUnstable_EnableTryIncRef(PyObject *op)
353355

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

‎pythoncapi_compat.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2543,7 +2543,9 @@ static inline int PyUnstable_Object_IsUniquelyReferenced(PyObject *obj)
25432543
// gh-128926 added PyUnstable_TryIncRef() and PyUnstable_EnableTryIncRef() to
25442544
// Python 3.14. Adapted from _Py_TryIncref() and _PyObject_SetMaybeWeakref().
25452545
// Not available on PyPy: Py_REFCNT() semantics is different on PyPy.
2546-
#if PY_VERSION_HEX < _Py_PACK_VERSION(3, 14) && !defined(PYPY_VERSION)
2546+
// Not available on the limited C API.
2547+
#if (PY_VERSION_HEX < _Py_PACK_VERSION(3, 14) \
2548+
&& !defined(PYPY_VERSION) && !defined(Py_LIMITED_API))
25472549
static inline int PyUnstable_TryIncRef(PyObject *op)
25482550
{
25492551
#ifndef Py_GIL_DISABLED

‎tests/test_pythoncapi_compat_cext.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2593,6 +2593,7 @@ test_try_incref(PyObject *Py_UNUSED(module), PyObject *Py_UNUSED(args))
25932593
#endif // !defined(PYPY_VERSION) && !defined(Py_LIMITED_API)
25942594

25952595

2596+
// Test PyUnstable_SetImmortal()
25962597
#if (_Py_PACK_VERSION(3, 13) <= PY_VERSION_HEX \
25972598
&& !defined(PYPY_VERSION) && !defined(Py_LIMITED_API))
25982599
static PyObject *

0 commit comments

Comments
 (0)