Skip to content

Commit 31da1a3

Browse files
reword
1 parent e4c71c5 commit 31da1a3

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

Doc/c-api/tuple.rst

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,12 @@ Tuple Objects
8080
:c:func:`Py_NewRef(PyTuple_GetItem(...)) <Py_NewRef>`
8181
or :c:func:`PySequence_GetItem`.
8282
83+
8384
.. c:function:: PyObject* PyTuple_GET_ITEM(PyObject *p, Py_ssize_t pos)
8485
8586
Like :c:func:`PyTuple_GetItem`, but does no checking of its arguments.
8687
88+
8789
.. c:function:: PyObject* PyTuple_GetSlice(PyObject *p, Py_ssize_t low, Py_ssize_t high)
8890
8991
Return the slice of the tuple pointed to by *p* between *low* and *high*,
@@ -109,7 +111,7 @@ Tuple Objects
109111
.. c:function:: void PyTuple_SET_ITEM(PyObject *p, Py_ssize_t pos, PyObject *o)
110112
111113
Like :c:func:`PyTuple_SetItem`, but does no error checking, and should *only* be
112-
used to fill in brand new tuples. Using it on an existing tuple is thread-unsafe.
114+
used to fill in brand new tuples, using it on an existing tuple is thread-unsafe.
113115
114116
Bounds checking is performed as an assertion if Python is built in
115117
:ref:`debug mode <debug-build>` or :option:`with assertions <--with-assertions>`.
@@ -121,6 +123,12 @@ Tuple Objects
121123
is being replaced; any reference in the tuple at position *pos* will be
122124
leaked.
123125
126+
.. warning::
127+
128+
This macro should *only* be used on tuples that are newly created.
129+
Using this macro on a tuple that is already in use (or in other words, has
130+
a refcount > 1) could lead to undefined behavior.
131+
124132
125133
.. c:function:: int _PyTuple_Resize(PyObject **p, Py_ssize_t newsize)
126134
@@ -135,11 +143,6 @@ Tuple Objects
135143
``*p`` is destroyed. On failure, returns ``-1`` and sets ``*p`` to ``NULL``, and
136144
raises :exc:`MemoryError` or :exc:`SystemError`.
137145
138-
.. note::
139-
140-
In the :term:`free-threaded build`, this function must only be used on
141-
tuples that are not yet visible to other threads.
142-
143146
144147
.. _struct-sequence-objects:
145148
@@ -240,6 +243,7 @@ type.
240243
Bounds checking is performed as an assertion if Python is built in
241244
:ref:`debug mode <debug-build>` or :option:`with assertions <--with-assertions>`.
242245
246+
243247
.. c:function:: PyObject* PyStructSequence_GET_ITEM(PyObject *p, Py_ssize_t pos)
244248
245249
Alias to :c:func:`PyStructSequence_GetItem`.

0 commit comments

Comments
 (0)