if (first) {
tmp = self->first;
- Py_INCREF(first);
- self->first = first;
+ self->first = Py_NewRef(first);
Py_XDECREF(tmp);
}
if (last) {
tmp = self->last;
- Py_INCREF(last);
- self->last = last;
+ self->last = Py_NewRef(last);
Py_XDECREF(tmp);
}
return 0;
if (m == NULL)
return NULL;
- Py_INCREF(&CustomType);
- if (PyModule_AddObject(m, "Custom", (PyObject *) &CustomType) < 0) {
- Py_DECREF(&CustomType);
+ if (PyModule_AddObjectRef(m, "Custom", (PyObject *) &CustomType) < 0) {
Py_DECREF(m);
return NULL;
}
if (first) {
tmp = self->first;
- Py_INCREF(first);
- self->first = first;
+ self->first = Py_NewRef(first);
Py_DECREF(tmp);
}
if (last) {
tmp = self->last;
- Py_INCREF(last);
- self->last = last;
+ self->last = Py_NewRef(last);
Py_DECREF(tmp);
}
return 0;
static PyObject *
Custom_getfirst(CustomObject *self, void *closure)
{
- Py_INCREF(self->first);
- return self->first;
+ return Py_NewRef(self->first);
}
static int
return -1;
}
tmp = self->first;
- Py_INCREF(value);
- self->first = value;
+ self->first = Py_NewRef(value);
Py_DECREF(tmp);
return 0;
}
static PyObject *
Custom_getlast(CustomObject *self, void *closure)
{
- Py_INCREF(self->last);
- return self->last;
+ return Py_NewRef(self->last);
}
static int
return -1;
}
tmp = self->last;
- Py_INCREF(value);
- self->last = value;
+ self->last = Py_NewRef(value);
Py_DECREF(tmp);
return 0;
}
if (m == NULL)
return NULL;
- Py_INCREF(&CustomType);
- if (PyModule_AddObject(m, "Custom", (PyObject *) &CustomType) < 0) {
- Py_DECREF(&CustomType);
+ if (PyModule_AddObjectRef(m, "Custom", (PyObject *) &CustomType) < 0) {
Py_DECREF(m);
return NULL;
}
if (first) {
tmp = self->first;
- Py_INCREF(first);
- self->first = first;
+ self->first = Py_NewRef(first);
Py_DECREF(tmp);
}
if (last) {
tmp = self->last;
- Py_INCREF(last);
- self->last = last;
+ self->last = Py_NewRef(last);
Py_DECREF(tmp);
}
return 0;
static PyObject *
Custom_getfirst(CustomObject *self, void *closure)
{
- Py_INCREF(self->first);
- return self->first;
+ return Py_NewRef(self->first);
}
static int
static PyObject *
Custom_getlast(CustomObject *self, void *closure)
{
- Py_INCREF(self->last);
- return self->last;
+ return Py_NewRef(self->last);
}
static int
if (m == NULL)
return NULL;
- Py_INCREF(&CustomType);
- if (PyModule_AddObject(m, "Custom", (PyObject *) &CustomType) < 0) {
- Py_DECREF(&CustomType);
+ if (PyModule_AddObjectRef(m, "Custom", (PyObject *) &CustomType) < 0) {
Py_DECREF(m);
return NULL;
}