From cba65de5496b8b5be903ed412877f265314b9bd1 Mon Sep 17 00:00:00 2001 From: Donghee Na Date: Fri, 12 Jul 2024 00:58:11 +0900 Subject: [PATCH] gh-121403: Add notes for PyList_GetXXX APIs about the need for init --- Doc/c-api/list.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Doc/c-api/list.rst b/Doc/c-api/list.rst index 53eb54d3e1021a3..f4bc138594e3fc4 100644 --- a/Doc/c-api/list.rst +++ b/Doc/c-api/list.rst @@ -65,17 +65,29 @@ List Objects .. versionadded:: 3.13 + .. note:: + You can not use this function until all items are set to real objects + with :c:func:`PyList_SetItem` or :c:func:`PyList_SET_ITEM`. + .. c:function:: PyObject* PyList_GetItem(PyObject *list, Py_ssize_t index) Like :c:func:`PyList_GetItemRef`, but returns a :term:`borrowed reference` instead of a :term:`strong reference`. + .. note:: + You can not use this function until all items are set to real objects + with :c:func:`PyList_SetItem` or :c:func:`PyList_SET_ITEM`. + .. c:function:: PyObject* PyList_GET_ITEM(PyObject *list, Py_ssize_t i) Similar to :c:func:`PyList_GetItem`, but without error checking. + .. note:: + You can not use this function until all items are set to real objects + with :c:func:`PyList_SetItem` or :c:func:`PyList_SET_ITEM`. + .. c:function:: int PyList_SetItem(PyObject *list, Py_ssize_t index, PyObject *item)