https://github.com/python/cpython/commit/15be34ade88cd06ef637f5726d85f1e7d0ef4c18
commit: 15be34ade88cd06ef637f5726d85f1e7d0ef4c18
branch: 3.12
author: Miss Islington (bot) <[email protected]>
committer: vstinner <[email protected]>
date: 2024-04-19T10:57:51+02:00
summary:

[3.12] gh-117518: Clarify PyTuple_GetItem() borrowed reference in the doc 
(GH-117920) (#118087)

gh-117518: Clarify PyTuple_GetItem() borrowed reference in the doc (GH-117920)
(cherry picked from commit 4605a197bd84da1a232bd835d8e8e654f2fef220)

Co-authored-by: Victor Stinner <[email protected]>

files:
M Doc/c-api/tuple.rst

diff --git a/Doc/c-api/tuple.rst b/Doc/c-api/tuple.rst
index 9bc3dab0c9c12c..e0186c1f5229c1 100644
--- a/Doc/c-api/tuple.rst
+++ b/Doc/c-api/tuple.rst
@@ -59,6 +59,12 @@ Tuple Objects
    Return the object at position *pos* in the tuple pointed to by *p*.  If 
*pos* is
    negative or out of bounds, return ``NULL`` and set an :exc:`IndexError` 
exception.
 
+   The returned reference is borrowed from the tuple *p*
+   (that is: it is only valid as long as you hold a reference to *p*).
+   To get a :term:`strong reference`, use
+   :c:func:`Py_NewRef(PyTuple_GetItem(...)) <Py_NewRef>`
+   or :c:func:`PySequence_GetItem`.
+
 
 .. c:function:: PyObject* PyTuple_GET_ITEM(PyObject *p, Py_ssize_t pos)
 

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to