Bug report
Bug description:
Not all usages of PyIter_Next in the codebase comply with specified behavior:
|
/* Return next item. |
|
* |
|
* If an error occurs, return NULL. PyErr_Occurred() will be true. |
|
* If the iteration terminates normally, return NULL and clear the |
|
* PyExc_StopIteration exception (if it was set). PyErr_Occurred() |
|
* will be false. |
|
* Else return the next object. PyErr_Occurred() will be false. |
|
*/ |
|
PyObject * |
|
PyIter_Next(PyObject *iter) |
|
{ |
|
PyObject *item; |
|
(void)iternext(iter, &item); |
|
return item; |
|
} |
.
One example would be:
|
while ((key = PyIter_Next(iter)) != NULL) { |
|
value = PyObject_GetItem(other, key); |
|
if (value == NULL) { |
|
Py_DECREF(key); |
|
Py_DECREF(iter); |
|
return -1; |
|
} |
|
|
|
if (framelocalsproxy_setitem(self, key, value) < 0) { |
|
Py_DECREF(key); |
|
Py_DECREF(value); |
|
Py_DECREF(iter); |
|
return -1; |
|
} |
|
|
|
Py_DECREF(key); |
|
Py_DECREF(value); |
|
} |
|
|
|
Py_DECREF(iter); |
|
|
|
return 0; |
|
} |
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
Bug report
Bug description:
Not all usages of
PyIter_Nextin the codebase comply with specified behavior:cpython/Objects/abstract.c
Lines 2905 to 2919 in 180d417
One example would be:
cpython/Objects/frameobject.c
Lines 246 to 268 in 180d417
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
Linked PRs
PyIter_Next#128199