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()) {
kwlist, &long_cnt, &long_step))
return NULL;
- if (long_cnt != NULL && !PyNumber_Check(long_cnt) ||
- long_step != NULL && !PyNumber_Check(long_step)) {
+ if ((long_cnt != NULL && !PyNumber_Check(long_cnt)) ||
+ (long_step != NULL && !PyNumber_Check(long_step))) {
PyErr_SetString(PyExc_TypeError, "a number is required");
return NULL;
}
} else
long_cnt = NULL;
}
- assert(cnt != PY_SSIZE_T_MAX && long_cnt == NULL ||
- cnt == PY_SSIZE_T_MAX && long_cnt != NULL);
+ assert((cnt != PY_SSIZE_T_MAX && long_cnt == NULL) ||
+ (cnt == PY_SSIZE_T_MAX && long_cnt != NULL));
/* create countobject structure */
lz = (countobject *)type->tp_alloc(type, 0);
Py_TYPE(lz)->tp_free(lz);
}
+static int
count_traverse(countobject *lz, visitproc visit, void *arg)
{
Py_VISIT(lz->long_cnt);
static PyObject *
count_nextlong(countobject *lz)
{
- static PyObject *one = NULL;
PyObject *long_cnt;
PyObject *stepped_up;