gh-121403: Add notes for PyList_GetXXX APIs about the need for init (gh-121626)

This commit is contained in:
Donghee Na 2024-07-16 10:16:41 +09:00 committed by GitHub
parent 498a94c198
commit 2bac2b86b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 3 deletions

View File

@ -38,9 +38,12 @@ List Objects
.. note:: .. note::
If *len* is greater than zero, the returned list object's items are If *len* is greater than zero, the returned list object's items are
set to ``NULL``. Thus you cannot use abstract API functions such as set to ``NULL``. Thus you cannot use abstract API functions such as
:c:func:`PySequence_SetItem` or expose the object to Python code before :c:func:`PySequence_SetItem` or expose the object to Python code before
setting all items to a real object with :c:func:`PyList_SetItem`. setting all items to a real object with :c:func:`PyList_SetItem` or
:c:func:`PyList_SET_ITEM()`. The following APIs are safe APIs before
the list is fully initialized: :c:func:`PyList_SetItem()` and :c:func:`PyList_SET_ITEM()`.
.. c:function:: Py_ssize_t PyList_Size(PyObject *list) .. c:function:: Py_ssize_t PyList_Size(PyObject *list)