do {
i++;
val = PyLong_FromLong(s[i]);
- if (!val)
- break;
- if (PyList_SetItem(result, i, val)) {
- Py_DECREF(val);
- val = NULL;
- break;
+ if (val == NULL) {
+ Py_DECREF(result);
+ return NULL;
}
+ PyList_SET_ITEM(result, i, val);
} while (s[i] != '\0' && s[i] != CHAR_MAX);
- if (!val) {
- Py_DECREF(result);
- return NULL;
- }
-
return result;
}
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);
if ((*self->ob_descr->setitem)(self,
Py_SIZE(self) - n + i, v) != 0) {
array_resize(self, old_size);
return NULL;
}
+ if (n != PyList_GET_SIZE(list)) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "list changed size during iteration");
+ array_resize(self, old_size);
+ return NULL;
+ }
}
}
Py_RETURN_NONE;
PyObject *v = getarrayitem((PyObject *)self, i);
if (v == NULL)
goto error;
- if (PyList_SetItem(list, i, v) < 0)
- goto error;
+ PyList_SET_ITEM(list, i, v);
}
return list;
s = decode(matches[i+1]);
if (s == NULL)
goto error;
- if (PyList_SetItem(m, i, s) == -1)
- goto error;
+ PyList_SET_ITEM(m, i, s);
}
sub = decode(matches[0]);
r = PyObject_CallFunction(readlinestate_global->completion_display_matches_hook,
goto error;
}
PyTuple_SET_ITEM(value, 1, num);
- if ((PyList_SetItem(result_list, j, value)) == -1) {
- Py_DECREF(value);
- goto error;
- }
+ PyList_SET_ITEM(result_list, j, value);
i++;
}
return result_list;
Py_DECREF(num2);
if (value == NULL)
goto error;
- if ((PyList_SetItem(result_list, i, value)) == -1) {
- Py_DECREF(value);
- goto error;
- }
+ PyList_SET_ITEM(result_list, i, value);
}
return result_list;
PyMem_Free(str);
return NULL;
}
- PyList_SetItem(obData,
- index,
- PyUnicode_FromWideChar(str[index], len));
+ PyObject *uni = PyUnicode_FromWideChar(str[index], len);
+ if (uni == NULL) {
+ Py_DECREF(obData);
+ PyMem_Free(str);
+ return NULL;
+ }
+ PyList_SET_ITEM(obData, index, uni);
}
PyMem_Free(str);
Py_DECREF(l);
return NULL;
}
- PyList_SetItem(l, i, x);
+ PyList_SET_ITEM(l, i, x);
}
for (i = 0; i < 256; i++)
a[i] = 0;
Py_DECREF(l);
return NULL;
}
- PyList_SetItem(l, i, x);
+ PyList_SET_ITEM(l, i, x);
}
return l;
#endif
Py_DECREF(v);
return NULL;
}
- PyList_SetItem(v, i, w);
+ PyList_SET_ITEM(v, i, w);
if (*p == '\0')
break;
path = p+1;