bpo-35441: Remove dead and buggy code related to PyList_SetItem() by ZackerySpytz · Pull Request #11033 · python/cpython
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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
In _localemodule.c and selectmodule.c, remove dead code that would
cause double decrefs if run.
In addition, replace PyList_SetItem() with PyList_SET_ITEM() in cases
where a new list is populated and there is no possibility of an error.
In _localemodule.c and selectmodule.c, remove dead code that would cause double decrefs if run. In addition, replace PyList_SetItem() with PyList_SET_ITEM() in cases where a new list is populated and there is no possibility of an error.
| @@ -1544,7 +1544,7 @@ array_array_fromlist(arrayobject *self, PyObject *list) | |||
| if (array_resize(self, old_size + n) == -1) | |||
| return NULL; | |||
| for (i = 0; i < n; i++) { | |||
| PyObject *v = PyList_GetItem(list, i); | |||
| PyObject *v = PyList_GET_ITEM(list, i); | |||
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is possible the the list change size when convert its items to C integers. PyList_GetItem() can return NULL.
Needed to check either that v != NULL, or that n == PyList_GET_SIZE() in a loop.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry. As this is a bug in the existing code, can I simply revert this change?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is up to you. Either revert this change and create a separate PR for fixing this bug, or include a fix for it in this PR.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.
Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request
Dec 8, 2018…ythonGH-11033) In _localemodule.c and selectmodule.c, remove dead code that would cause double decrefs if run. In addition, replace PyList_SetItem() with PyList_SET_ITEM() in cases where a new list is populated and there is no possibility of an error. In addition, check if the list changed size in the loop in array_array_fromlist(). (cherry picked from commit 99d56b5) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request
Dec 8, 2018…ythonGH-11033) In _localemodule.c and selectmodule.c, remove dead code that would cause double decrefs if run. In addition, replace PyList_SetItem() with PyList_SET_ITEM() in cases where a new list is populated and there is no possibility of an error. In addition, check if the list changed size in the loop in array_array_fromlist(). (cherry picked from commit 99d56b5) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Sorry, @ZackerySpytz and @serhiy-storchaka, I could not cleanly backport this to 2.7 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 99d56b53560b3867844472ae381fb3f858760621 2.7
miss-islington added a commit that referenced this pull request
Dec 8, 2018…H-11033) In _localemodule.c and selectmodule.c, remove dead code that would cause double decrefs if run. In addition, replace PyList_SetItem() with PyList_SET_ITEM() in cases where a new list is populated and there is no possibility of an error. In addition, check if the list changed size in the loop in array_array_fromlist(). (cherry picked from commit 99d56b5) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
miss-islington added a commit that referenced this pull request
Dec 8, 2018…H-11033) In _localemodule.c and selectmodule.c, remove dead code that would cause double decrefs if run. In addition, replace PyList_SetItem() with PyList_SET_ITEM() in cases where a new list is populated and there is no possibility of an error. In addition, check if the list changed size in the loop in array_array_fromlist(). (cherry picked from commit 99d56b5) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
serhiy-storchaka pushed a commit to serhiy-storchaka/cpython that referenced this pull request
Dec 19, 2018…(). (pythonGH-11033) In _localemodule.c and selectmodule.c, remove dead code that would cause double decrefs if run. In addition, replace PyList_SetItem() with PyList_SET_ITEM() in cases where a new list is populated and there is no possibility of an error. In addition, check if the list changed size in the loop in array_array_fromlist().. (cherry picked from commit 99d56b5) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
serhiy-storchaka added a commit that referenced this pull request
Dec 19, 2018…(). (GH-11033) (GH-11234) In _localemodule.c and selectmodule.c, remove dead code that would cause double decrefs if run. In addition, replace PyList_SetItem() with PyList_SET_ITEM() in cases where a new list is populated and there is no possibility of an error. In addition, check if the list changed size in the loop in array_array_fromlist(). (cherry picked from commit 99d56b5) Co-authored-by: Zackery Spytz <zspytz@gmail.com>