summaryrefslogtreecommitdiffstats
path: root/Doc/c-api/refcounting.rst
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2023-12-01 14:50:16 (GMT)
committerGitHub <noreply@github.com>2023-12-01 14:50:16 (GMT)
commit5f6ac2d88a49b8a7c764691365cd41ee6226a8d0 (patch)
tree317433a73a42b5b11d85ff220d8238f76171d0f5 /Doc/c-api/refcounting.rst
parentc2982380f827e53057068eccf9f1a16b5a653728 (diff)
downloadcpython-5f6ac2d88a49b8a7c764691365cd41ee6226a8d0.zip
cpython-5f6ac2d88a49b8a7c764691365cd41ee6226a8d0.tar.gz
cpython-5f6ac2d88a49b8a7c764691365cd41ee6226a8d0.tar.bz2
gh-110481: Fix Py_SET_REFCNT() integer overflow (#112174)
If Py_NOGIL is defined and Py_SET_REFCNT() is called with a reference count larger than UINT32_MAX, make the object immortal. Set _Py_IMMORTAL_REFCNT constant type to Py_ssize_t to fix the following compiler warning: Include/internal/pycore_global_objects_fini_generated.h:14:24: warning: comparison of integers of different signs: 'Py_ssize_t' (aka 'long') and 'unsigned int' [-Wsign-compare] if (Py_REFCNT(obj) < _Py_IMMORTAL_REFCNT) { ~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~
Diffstat (limited to 'Doc/c-api/refcounting.rst')
-rw-r--r--Doc/c-api/refcounting.rst3
1 files changed, 3 insertions, 0 deletions
diff --git a/Doc/c-api/refcounting.rst b/Doc/c-api/refcounting.rst
index 68119a2..75e1d46 100644
--- a/Doc/c-api/refcounting.rst
+++ b/Doc/c-api/refcounting.rst
@@ -34,6 +34,9 @@ of Python objects.
Set the object *o* reference counter to *refcnt*.
+ On :ref:`Python build with Free Threading <free-threading-build>`, if
+ *refcnt* is larger than ``UINT32_MAX``, the object is made :term:`immortal`.
+
This function has no effect on :term:`immortal` objects.
.. versionadded:: 3.9