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
2 changes: 2 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,8 @@ PyObject

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

Not available on Free Threading with limited C API 3.15 or newer (abi3t).

.. c:function:: void Py_SET_SIZE(PyVarObject *ob, Py_ssize_t size)

See `Py_SET_SIZE() documentation <https://docs.python.org/dev/c-api/structures.html#c.Py_SET_SIZE>`__.
Expand Down
6 changes: 4 additions & 2 deletions tests/test_pythoncapi_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,15 @@ def run_tests(build_dir, module_name, std):
if VERBOSE:
empty_line = False
for attr in ('__cplusplus', 'PY_VERSION', 'PY_VERSION_HEX',
'PYPY_VERSION', 'PYPY_VERSION_NUM', 'Py_LIMITED_API'):
'PYPY_VERSION', 'PYPY_VERSION_NUM', 'Py_LIMITED_API',
'Py_TARGET_ABI3T'):
try:
value = getattr(testmod, attr)
except AttributeError:
pass
else:
if attr in ('PY_VERSION_HEX', 'Py_LIMITED_API', 'PYPY_VERSION_NUM'):
if attr in ('PY_VERSION_HEX', 'Py_LIMITED_API',
'PYPY_VERSION_NUM', 'Py_TARGET_ABI3T'):
value = "0x%x" % value
print("%s: %s" % (attr, value))
empty_line = True
Expand Down
11 changes: 8 additions & 3 deletions tests/test_pythoncapi_compat_cext.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ test_object(PyObject *Py_UNUSED(module), PyObject* Py_UNUSED(ignored))

// Py_SET_REFCNT
Py_SET_REFCNT(obj, Py_REFCNT(obj));
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < _Py_PACK_VERSION(3, 10)
// Py_SET_TYPE
// Py_SET_TYPE. Not implemented in the abi3t.
#ifndef Py_TARGET_ABI3T
Py_SET_TYPE(obj, Py_TYPE(obj));
#endif
// Py_SET_SIZE
Expand Down Expand Up @@ -315,7 +315,7 @@ test_thread_state(PyObject *Py_UNUSED(module), PyObject* Py_UNUSED(ignored))
static PyObject *
test_interpreter(PyObject *Py_UNUSED(module), PyObject* Py_UNUSED(ignored))
{
// On Windows,PyInterpreterState_Get() is not available in stable ABI 3.9,
// On Windows, PyInterpreterState_Get() is not available in stable ABI 3.9,
// only in stable ABI 3.10. Don't test it on limited C API 3.9 on Unix to
// make the test simpler.
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= _Py_PACK_VERSION(3, 10)
Expand Down Expand Up @@ -2802,6 +2802,11 @@ module_exec(PyObject *module)
return -1;
}
#endif
#ifdef Py_TARGET_ABI3T
if (PyModule_AddIntMacro(module, Py_TARGET_ABI3T)) {
return -1;
}
#endif
#if !defined(PYPY_VERSION) && !defined(Py_LIMITED_API)
TryIncrefType.tp_name = "TryIncrefType";
TryIncrefType.tp_basicsize = sizeof(PyObject);
Expand Down
Loading