gbo->tgtkey = NULL;
gbo->currkey = NULL;
gbo->currvalue = NULL;
- gbo->keyfunc = keyfunc;
- Py_INCREF(keyfunc);
+ gbo->keyfunc = Py_NewRef(keyfunc);
gbo->it = PyObject_GetIter(it);
if (gbo->it == NULL) {
Py_DECREF(gbo);
return -1;
if (gbo->keyfunc == Py_None) {
- newkey = newvalue;
- Py_INCREF(newvalue);
+ newkey = Py_NewRef(newvalue);
} else {
newkey = PyObject_CallOneArg(gbo->keyfunc, newvalue);
if (newkey == NULL) {
igo = PyObject_GC_New(_grouperobject, &_grouper_type);
if (igo == NULL)
return NULL;
- igo->parent = (PyObject *)parent;
- Py_INCREF(parent);
- igo->tgtkey = tgtkey;
- Py_INCREF(tgtkey);
+ igo->parent = Py_NewRef(parent);
+ igo->tgtkey = Py_NewRef(tgtkey);
parent->currgrouper = igo; /* borrowed reference */
PyObject_GC_Track(igo);
tdo->running = 0;
tdo->numread = 0;
tdo->nextlink = NULL;
- Py_INCREF(it);
- tdo->it = it;
+ tdo->it = Py_NewRef(it);
PyObject_GC_Track(tdo);
return (PyObject *)tdo;
}
{
if (tdo->nextlink == NULL)
tdo->nextlink = teedataobject_newinternal(tdo->it);
- Py_XINCREF(tdo->nextlink);
- return tdo->nextlink;
+ return Py_XNewRef(tdo->nextlink);
}
static PyObject *
tdo->numread++;
tdo->values[i] = value;
}
- Py_INCREF(value);
- return value;
+ return Py_NewRef(value);
}
static int
if (!Py_IS_TYPE(next, &teedataobject_type))
goto err;
assert(tdo->nextlink == NULL);
- Py_INCREF(next);
- tdo->nextlink = next;
+ tdo->nextlink = Py_NewRef(next);
}
} else {
if (next != Py_None)
newto = PyObject_GC_New(teeobject, &tee_type);
if (newto == NULL)
return NULL;
- Py_INCREF(to->dataobj);
- newto->dataobj = to->dataobj;
+ newto->dataobj = (teedataobject*)Py_NewRef(to->dataobj);
newto->index = to->index;
newto->weakreflist = NULL;
PyObject_GC_Track(newto);
lz->index++;
if (lz->index >= PyList_GET_SIZE(lz->saved))
lz->index = 0;
- Py_INCREF(item);
- return item;
+ return Py_NewRef(item);
}
static PyObject *
Py_DECREF(it);
return NULL;
}
- Py_INCREF(func);
- lz->func = func;
+ lz->func = Py_NewRef(func);
lz->it = it;
lz->start = 0;
Py_DECREF(it);
return NULL;
}
- Py_INCREF(func);
- lz->func = func;
+ lz->func = Py_NewRef(func);
lz->it = it;
lz->stop = 0;
return Py_BuildValue("O(Nn)n", Py_TYPE(lz), empty_it, 0, 0);
}
if (lz->stop == -1) {
- stop = Py_None;
- Py_INCREF(stop);
+ stop = Py_NewRef(Py_None);
} else {
stop = PyLong_FromSsize_t(lz->stop);
if (stop == NULL)
Py_DECREF(it);
return NULL;
}
- Py_INCREF(func);
- lz->func = func;
+ lz->func = Py_NewRef(func);
lz->it = it;
return (PyObject *)lz;
goto empty;
}
- Py_INCREF(result);
- return result;
+ return Py_NewRef(result);
empty:
lz->stopped = 1;
}
}
- Py_INCREF(result);
- return result;
+ return Py_NewRef(result);
empty:
co->stopped = 1;
}
}
- Py_INCREF(result);
- return result;
+ return Py_NewRef(result);
empty:
co->stopped = 1;
if (i < 0)
goto empty;
}
- Py_INCREF(result);
- return result;
+ return Py_NewRef(result);
empty:
po->stopped = 1;
}
if (binop != Py_None) {
- Py_XINCREF(binop);
- lz->binop = binop;
+ lz->binop = Py_XNewRef(binop);
}
lz->total = NULL;
lz->it = it;
- Py_XINCREF(initial);
- lz->initial = initial;
+ lz->initial = Py_XNewRef(initial);
return (PyObject *)lz;
}
if (lz->initial != Py_None) {
lz->total = lz->initial;
- Py_INCREF(Py_None);
- lz->initial = Py_None;
- Py_INCREF(lz->total);
- return lz->total;
+ lz->initial = Py_NewRef(Py_None);
+ return Py_NewRef(lz->total);
}
val = (*Py_TYPE(lz->it)->tp_iternext)(lz->it);
if (val == NULL)
return NULL;
if (lz->total == NULL) {
- Py_INCREF(val);
- lz->total = val;
+ lz->total = Py_NewRef(val);
return lz->total;
}
Py_DECREF(it);
return NULL;
}
- Py_INCREF(func);
- lz->func = func;
+ lz->func = Py_NewRef(func);
lz->it = it;
return (PyObject *)lz;
ro = (repeatobject *)type->tp_alloc(type, 0);
if (ro == NULL)
return NULL;
- Py_INCREF(element);
- ro->element = element;
+ ro->element = Py_NewRef(element);
ro->cnt = cnt;
return (PyObject *)ro;
}
return NULL;
if (ro->cnt > 0)
ro->cnt--;
- Py_INCREF(ro->element);
- return ro->element;
+ return Py_NewRef(ro->element);
}
static PyObject *
lz->tuplesize = tuplesize;
lz->numactive = tuplesize;
lz->result = result;
- Py_INCREF(fillvalue);
- lz->fillvalue = fillvalue;
+ lz->fillvalue = Py_NewRef(fillvalue);
return (PyObject *)lz;
}
for (i=0 ; i < tuplesize ; i++) {
it = PyTuple_GET_ITEM(lz->ittuple, i);
if (it == NULL) {
- Py_INCREF(lz->fillvalue);
- item = lz->fillvalue;
+ item = Py_NewRef(lz->fillvalue);
} else {
item = PyIter_Next(it);
if (item == NULL) {
Py_DECREF(result);
return NULL;
} else {
- Py_INCREF(lz->fillvalue);
- item = lz->fillvalue;
+ item = Py_NewRef(lz->fillvalue);
PyTuple_SET_ITEM(lz->ittuple, i, NULL);
Py_DECREF(it);
}
for (i=0 ; i < tuplesize ; i++) {
it = PyTuple_GET_ITEM(lz->ittuple, i);
if (it == NULL) {
- Py_INCREF(lz->fillvalue);
- item = lz->fillvalue;
+ item = Py_NewRef(lz->fillvalue);
} else {
item = PyIter_Next(it);
if (item == NULL) {
Py_DECREF(result);
return NULL;
} else {
- Py_INCREF(lz->fillvalue);
- item = lz->fillvalue;
+ item = Py_NewRef(lz->fillvalue);
PyTuple_SET_ITEM(lz->ittuple, i, NULL);
Py_DECREF(it);
}