Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add missing error checks for usages ofPyIter_Next #128198

Closed
Labels
3.12only security fixes3.13bugs and security fixes3.14bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error
@WolframAlph

Description

@WolframAlph

Bug report

Bug description:

Not all usages ofPyIter_Next in the codebase comply with specified behavior:

cpython/Objects/abstract.c

Lines 2905 to 2919 in180d417

/* 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);
returnitem;
}
.
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);
return0;
}

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixes3.13bugs and security fixes3.14bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp