Skip to content

Commit cba65de

Browse files
committed
gh-121403: Add notes for PyList_GetXXX APIs about the need for init
1 parent 58e8cf2 commit cba65de

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Doc/c-api/list.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,29 @@ List Objects
6565
6666
.. versionadded:: 3.13
6767
68+
.. note::
69+
You can not use this function until all items are set to real objects
70+
with :c:func:`PyList_SetItem` or :c:func:`PyList_SET_ITEM`.
71+
6872
6973
.. c:function:: PyObject* PyList_GetItem(PyObject *list, Py_ssize_t index)
7074
7175
Like :c:func:`PyList_GetItemRef`, but returns a
7276
:term:`borrowed reference` instead of a :term:`strong reference`.
7377
78+
.. note::
79+
You can not use this function until all items are set to real objects
80+
with :c:func:`PyList_SetItem` or :c:func:`PyList_SET_ITEM`.
81+
7482
7583
.. c:function:: PyObject* PyList_GET_ITEM(PyObject *list, Py_ssize_t i)
7684
7785
Similar to :c:func:`PyList_GetItem`, but without error checking.
7886
87+
.. note::
88+
You can not use this function until all items are set to real objects
89+
with :c:func:`PyList_SetItem` or :c:func:`PyList_SET_ITEM`.
90+
7991
8092
.. c:function:: int PyList_SetItem(PyObject *list, Py_ssize_t index, PyObject *item)
8193

0 commit comments

Comments
 (0)