Skip to content

Commit 041a566

Browse files
GH-117283: Add doc warning for PyTuple_SetItem refcount > 1 (#117916)
1 parent 3b26cd8 commit 041a566

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Doc/c-api/tuple.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ Tuple Objects
105105
is being replaced; any reference in the tuple at position *pos* will be
106106
leaked.
107107
108+
.. warning::
109+
110+
This macro should *only* be used on tuples that are newly created.
111+
Using this macro on a tuple that is already in use (or in other words, has
112+
a refcount > 1) could lead to undefined behavior.
113+
108114
109115
.. c:function:: int _PyTuple_Resize(PyObject **p, Py_ssize_t newsize)
110116

0 commit comments

Comments
 (0)