Skip to content

Commit

Permalink
pythongh-117518: Clarify PyTuple_GetItem() borrowed reference in the …
Browse files Browse the repository at this point in the history
  • Loading branch information
vstinner authored Apr 19, 2024
1 parent 7e6fa5f commit 4605a19
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Doc/c-api/tuple.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4605a19

Please sign in to comment.