-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
gh-128198: Add missing error checks for usages of PyIter_Next
#128199
base: main
Are you sure you want to change the base?
Conversation
1c58e95
to
ca54407
Compare
ca54407
to
c6d319f
Compare
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.
In 3.14, we have a new PyIter_NextItem
for exactly this problem. I think it's worth migrating to that in this PR instead of trying to adapt to the bad design choices of PyIter_Next
.
👍 Will check it out and update the PR |
@ZeroIntensity I can see |
I don't think we need to replace
Nah, just update the PR title. |
@ZeroIntensity so if this is inevitable (otherwise why would new |
@@ -1667,10 +1667,13 @@ deque_richcompare(PyObject *v, PyObject *w, int op) | |||
if (it2 == NULL) | |||
goto done; | |||
for (;;) { | |||
x = PyIter_Next(it1); | |||
if (x == NULL && PyErr_Occurred()) | |||
if ((x = PyIter_Next(it1)) == NULL && PyErr_Occurred()) { |
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.
This is equivalent to what was before. Please revert.
y = PyIter_Next(it2); | ||
} | ||
if ((y = PyIter_Next(it2)) == NULL && PyErr_Occurred()) { | ||
Py_XDECREF(x); |
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.
This is already handled by lines 1677 + 1689 + 1691. PLease revert.
|
||
/* Check if loop ended because of exception in PyIter_Next */ | ||
if (PyErr_Occurred()) { | ||
return NULL; |
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.
You need to decref the tasks as well.
PyIter_Next
PyIter_Next
PyIter_Next
#128198