-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
GH-59313: Do not allow incomplete tuples, or tuples with NULLs. #117747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d4d6f24
6a1f806
9aeb6da
40a49d6
0a06553
207005c
03643cf
0d8974e
8fad5a4
e4b4f39
f4c0a29
bf69fc5
4d0ad9e
269832a
3a766d8
003264f
a155802
ae437f1
03ce121
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ static inline Py_ssize_t PyTuple_GET_SIZE(PyObject *op) { | |
static inline void | ||
PyTuple_SET_ITEM(PyObject *op, Py_ssize_t index, PyObject *value) { | ||
PyTupleObject *tuple = _PyTuple_CAST(op); | ||
assert(value != NULL); | ||
vstinner marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You modified PyTuple_SET_ITEM() but not PyTuple_SetItem(), is it on purpose? I suggest to modify both, since PyTuple_SetItem() doesn't call PyTuple_SET_ITEM(). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
assert(0 <= index); | ||
assert(index < Py_SIZE(tuple)); | ||
tuple->ob_item[index] = value; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Make sure that all tuple elements are valid and never NULL. Ensuring that | ||
tuples are always valid reduces the risk of cycle GC bugs and prevents | ||
``gc.get_referrers`` from returning invalid tuples. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move this addition to PyTuple_SetItem(), since PyTuple_SET_ITEM() is "like PyTuple_SetItem()"?
Or just copy/paste the sentence in PyTuple_SetItem() doc?