PyList_Append() can fail

This commit is contained in:
Benjamin Peterson 2009-02-16 21:23:04 +00:00
parent 5781f32b4f
commit a7b0c12152
1 changed files with 4 additions and 2 deletions

View File

@ -745,8 +745,10 @@ cycle_next(cycleobject *lz)
while (1) {
item = PyIter_Next(lz->it);
if (item != NULL) {
if (!lz->firstpass)
PyList_Append(lz->saved, item);
if (!lz->firstpass && PyList_Append(lz->saved, item)) {
Py_DECREF(item);
return NULL;
}
return item;
}
if (PyErr_Occurred()) {