Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 33.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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
d4d6f246a1f8069aeb6da40a49d60a06553207005c03643cf0d8974e8fad5a4e4b4f39f4c0a29bf69fc54d0ad9e269832a3a766d8003264fa155802ae437f103ce121File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
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 resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. Member 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(). MemberAuthor 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. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -3696,7 +3696,7 @@ zip_longest_next(ziplongestobject *lz) | ||
| Py_INCREF(result); | ||
| for (i=0 ; i < tuplesize ; i++){ | ||
| it = PyTuple_GET_ITEM(lz->ittuple, i); | ||
| if (it == NULL){ | ||
| if (it == Py_None){ | ||
erlend-aasland marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| item = Py_NewRef(lz->fillvalue); | ||
| } else{ | ||
| item = PyIter_Next(it); | ||
| @@ -3708,7 +3708,7 @@ zip_longest_next(ziplongestobject *lz) | ||
| return NULL; | ||
| } else{ | ||
| item = Py_NewRef(lz->fillvalue); | ||
| PyTuple_SET_ITEM(lz->ittuple, i, NULL); | ||
| PyTuple_SET_ITEM(lz->ittuple, i, Py_None); | ||
| Py_DECREF(it); | ||
| } | ||
| } | ||
| @@ -3728,7 +3728,7 @@ zip_longest_next(ziplongestobject *lz) | ||
| return NULL; | ||
| for (i=0 ; i < tuplesize ; i++){ | ||
| it = PyTuple_GET_ITEM(lz->ittuple, i); | ||
| if (it == NULL){ | ||
| if (it == Py_None){ | ||
erlend-aasland marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| item = Py_NewRef(lz->fillvalue); | ||
| } else{ | ||
| item = PyIter_Next(it); | ||
| @@ -3740,7 +3740,7 @@ zip_longest_next(ziplongestobject *lz) | ||
| return NULL; | ||
| } else{ | ||
| item = Py_NewRef(lz->fillvalue); | ||
| PyTuple_SET_ITEM(lz->ittuple, i, NULL); | ||
| PyTuple_SET_ITEM(lz->ittuple, i, Py_None); | ||
| Py_DECREF(it); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.
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?