gh-121403: Add notes for PyList_GetXXX APIs about the need for init#121626
Conversation
|
I am not sure if we have to add notes to all list-related APIs, but for me, this note looks more straightforward from the user side. |
vstinner
left a comment
There was a problem hiding this comment.
I would prefer to only add a note to PyList_New() instead.
Yeah, I was going to suggest the same thing. |
|
Victor, if you are thinking about the comment that you wrote before. #121403 (comment) |
|
I suggest to say that only PyList_SET_ITEM() is safe to call before the list is fully initialized. |
|
|
| :c:func:`PyList_SET_ITEM()`. The following APIs are safe APIs before | ||
| the list is fully initialized. | ||
| - :c:func:`PyList_SetItem()` | ||
| - :c:func:`PyList_SET_ITEM()` |
There was a problem hiding this comment.
The list is not rendered properly. Maybe just write: "The following ...: PyList_SetItem and PyList_SET_ITEM."
There was a problem hiding this comment.
|
Waiting @colesbury, who is the best English speaker in this place :) |
|
Thanks @corona10 for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13. |
…init (pythongh-121626) (cherry picked from commit 2bac2b8) Co-authored-by: Donghee Na <donghee.na@python.org>
|
GH-121827 is a backport of this pull request to the 3.13 branch. |
| :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()`. |
There was a problem hiding this comment.
Sorry for missing this PR while it was still open. I don't think this makes it clear enough that these are the only APIs that can be used before a list is fully initialized. Maybe something like this would be better?
| :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:func:`PyList_SET_ITEM()`. The following APIs are the only safe APIs to use before | |
| the list is fully initialized: :c:func:`PyList_SetItem()` and :c:func:`PyList_SET_ITEM()`. |
📚 Documentation preview 📚: https://cpython-previews--121626.org.readthedocs.build/