Custom_init(CustomObject *self, PyObject *args, PyObject *kwds)
{
static char *kwlist[] = {"first", "last", "number", NULL};
- PyObject *first = NULL, *last = NULL, *tmp;
+ PyObject *first = NULL, *last = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOi", kwlist,
&first, &last,
return -1;
if (first) {
- tmp = self->first;
- self->first = Py_NewRef(first);
- Py_XDECREF(tmp);
+ Py_XSETREF(self->first, Py_NewRef(first));
}
if (last) {
- tmp = self->last;
- self->last = Py_NewRef(last);
- Py_XDECREF(tmp);
+ Py_XSETREF(self->last, Py_NewRef(last));
}
return 0;
}
Custom_init(CustomObject *self, PyObject *args, PyObject *kwds)
{
static char *kwlist[] = {"first", "last", "number", NULL};
- PyObject *first = NULL, *last = NULL, *tmp;
+ PyObject *first = NULL, *last = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|UUi", kwlist,
&first, &last,
return -1;
if (first) {
- tmp = self->first;
- self->first = Py_NewRef(first);
- Py_DECREF(tmp);
+ Py_SETREF(self->first, Py_NewRef(first));
}
if (last) {
- tmp = self->last;
- self->last = Py_NewRef(last);
- Py_DECREF(tmp);
+ Py_SETREF(self->last, Py_NewRef(last));
}
return 0;
}
static int
Custom_setfirst(CustomObject *self, PyObject *value, void *closure)
{
- PyObject *tmp;
if (value == NULL) {
PyErr_SetString(PyExc_TypeError, "Cannot delete the first attribute");
return -1;
"The first attribute value must be a string");
return -1;
}
- tmp = self->first;
- self->first = Py_NewRef(value);
- Py_DECREF(tmp);
+ Py_SETREF(self->first, Py_NewRef(value));
return 0;
}
static int
Custom_setlast(CustomObject *self, PyObject *value, void *closure)
{
- PyObject *tmp;
if (value == NULL) {
PyErr_SetString(PyExc_TypeError, "Cannot delete the last attribute");
return -1;
"The last attribute value must be a string");
return -1;
}
- tmp = self->last;
- self->last = Py_NewRef(value);
- Py_DECREF(tmp);
+ Py_SETREF(self->last, Py_NewRef(value));
return 0;
}
Custom_init(CustomObject *self, PyObject *args, PyObject *kwds)
{
static char *kwlist[] = {"first", "last", "number", NULL};
- PyObject *first = NULL, *last = NULL, *tmp;
+ PyObject *first = NULL, *last = NULL;
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|UUi", kwlist,
&first, &last,
return -1;
if (first) {
- tmp = self->first;
- self->first = Py_NewRef(first);
- Py_DECREF(tmp);
+ Py_SETREF(self->first, Py_NewRef(first));
}
if (last) {
- tmp = self->last;
- self->last = Py_NewRef(last);
- Py_DECREF(tmp);
+ Py_SETREF(self->last, Py_NewRef(last));
}
return 0;
}
"The first attribute value must be a string");
return -1;
}
- Py_INCREF(value);
- Py_CLEAR(self->first);
- self->first = value;
+ Py_XSETREF(self->first, Py_NewRef(value));
return 0;
}
"The last attribute value must be a string");
return -1;
}
- Py_INCREF(value);
- Py_CLEAR(self->last);
- self->last = value;
+ Py_XSETREF(self->last, Py_NewRef(value));
return 0;
}
static int
deque_ass_item(dequeobject *deque, Py_ssize_t i, PyObject *v)
{
- PyObject *old_value;
block *b;
Py_ssize_t n, len=Py_SIZE(deque), halflen=(len+1)>>1, index=i;
while (--n >= 0)
b = b->leftlink;
}
- old_value = b->data[i];
- b->data[i] = Py_NewRef(v);
- Py_DECREF(old_value);
+ Py_SETREF(b->data[i], Py_NewRef(v));
return 0;
}
}
else {
/* Result is already aware - just replace tzinfo. */
- temp = result->tzinfo;
- result->tzinfo = Py_NewRef(PyDateTime_TimeZone_UTC);
- Py_DECREF(temp);
+ Py_SETREF(result->tzinfo, Py_NewRef(PyDateTime_TimeZone_UTC));
}
/* Attach new tzinfo and let fromutc() do the rest. */
- temp = result->tzinfo;
if (tzinfo == Py_None) {
tzinfo = local_timezone(result);
if (tzinfo == NULL) {
}
else
Py_INCREF(tzinfo);
- result->tzinfo = tzinfo;
- Py_DECREF(temp);
+ Py_SETREF(result->tzinfo, tzinfo);
temp = (PyObject *)result;
result = (PyDateTime_DateTime *)
if (!tmp)
return NULL;
self->text = tmp;
- Py_DECREF(res);
- res = tmp;
+ Py_SETREF(res, tmp);
}
}
if (!tmp)
return NULL;
self->tail = tmp;
- Py_DECREF(res);
- res = tmp;
+ Py_SETREF(res, tmp);
}
}
{
while (link != NULL) {
lru_list_elem *next = link->next;
- Py_DECREF(link);
- link = next;
+ Py_SETREF(link, next);
}
}
if (self->writenl) {
PyObject *translated = PyUnicode_Replace(
decoded, &_Py_STR(newline), self->writenl, -1);
- Py_DECREF(decoded);
- decoded = translated;
+ Py_SETREF(decoded, translated);
}
if (decoded == NULL)
return -1;
out = PyUnicode_DATA(modified);
PyUnicode_WRITE(kind, out, 0, '\r');
memcpy(out + kind, PyUnicode_DATA(output), kind * output_len);
- Py_DECREF(output);
- output = modified; /* output remains ready */
+ Py_SETREF(output, modified); /* output remains ready */
self->pendingcr = 0;
output_len++;
}
PyObject *modified = PyUnicode_Substring(output, 0, output_len -1);
if (modified == NULL)
goto error;
- Py_DECREF(output);
- output = modified;
+ Py_SETREF(output, modified);
self->pendingcr = 1;
}
}
self->decoder, self->readtranslate ? Py_True : Py_False, NULL);
if (incrementalDecoder == NULL)
return -1;
- Py_CLEAR(self->decoder);
- self->decoder = incrementalDecoder;
+ Py_XSETREF(self->decoder, incrementalDecoder);
}
return 0;
if (memokey == NULL) {
goto bail;
}
- Py_INCREF(memokey);
- Py_DECREF(key);
- key = memokey;
+ Py_SETREF(key, Py_NewRef(memokey));
idx = next_idx;
/* skip whitespace between key and : delimiter, read :, skip whitespace */
n = PyList_GET_SIZE(names);
for (i = 0; i < n; i++) {
PyObject *name = PyList_GET_ITEM(names, i);
- Py_XDECREF(parent);
- parent = obj;
+ Py_XSETREF(parent, obj);
(void)_PyObject_LookupAttr(parent, name, &obj);
if (obj == NULL) {
Py_DECREF(parent);
else {
gen_global:
if (parent == module) {
- Py_INCREF(lastname);
- Py_DECREF(global_name);
- global_name = lastname;
+ Py_SETREF(global_name, Py_NewRef(lastname));
}
if (self->proto >= 4) {
const char stack_global_op = STACK_GLOBAL;
PyObject *factory = self->row_factory;
PyObject *args[] = { (PyObject *)self, row, };
PyObject *new_row = PyObject_Vectorcall(factory, args, 2, NULL);
- Py_DECREF(row);
- row = new_row;
+ Py_SETREF(row, new_row);
}
return row;
}
PyErr_SetString(PyExc_TypeError, "argument must be a list");
return NULL;
}
- Py_CLEAR(record_list);
- record_list = Py_NewRef(list);
+ Py_XSETREF(record_list, Py_NewRef(list));
_PyInterpreterState_SetEvalFrameFunc(PyInterpreterState_Get(), record_eval);
Py_RETURN_NONE;
}
PyMem_Free(bytes);
if (res != NULL && bigValue.sign == MP_NEG) {
PyObject *res2 = PyNumber_Negative(res);
- Py_DECREF(res);
- res = res2;
+ Py_SETREF(res, res2);
}
mp_clear(&bigValue);
return res;
// that the dstoff is set correctly in that case.
if (PyObject_IsTrue(tti->dstoff)) {
_ttinfo *tti_after = &(self->tzrule_after.std);
- Py_DECREF(tti_after->dstoff);
- tti_after->dstoff = Py_NewRef(tti->dstoff);
+ Py_SETREF(tti_after->dstoff, Py_NewRef(tti->dstoff));
}
}
len = (Py_ssize_t)(ncp - PyBytes_AsString(str));
rv = PyBytes_FromStringAndSize
(PyBytes_AsString(str), len);
- Py_DECREF(str);
- str = rv;
+ Py_SETREF(str, rv);
if (str == NULL)
goto exit;
rv = Py_BuildValue("(O(iO))", str, d, samps);
goto errorexit;
}
- Py_CLEAR(self->pending);
- self->pending = pending;
+ Py_XSETREF(self->pending, pending);
memcpy(self->state.c, statebytes+1+statebytes[0],
sizeof(self->state.c));
memcpy(ctrdata + self->pendingsize,
PyBytes_AS_STRING(cres),
PyBytes_GET_SIZE(cres));
- Py_DECREF(cres);
- cres = ctr;
+ Py_SETREF(cres, ctr);
self->pendingsize = 0;
}
Py_REFCNT(obj) == 1) {
PyObject *nextlink = ((teedataobject *)obj)->nextlink;
((teedataobject *)obj)->nextlink = NULL;
- Py_DECREF(obj);
- obj = nextlink;
+ Py_SETREF(obj, nextlink);
}
Py_XDECREF(obj);
}
Py_DECREF(partial);
if (tmp == NULL)
goto error;
- Py_DECREF(inner);
- inner = tmp;
+ Py_SETREF(inner, tmp);
/* Now inner is the product of all odd integers j in the range (0,
n/2**i], giving the inner product in the formula above. */
tmp = PyNumber_Multiply(outer, inner);
if (tmp == NULL)
goto error;
- Py_DECREF(outer);
- outer = tmp;
+ Py_SETREF(outer, tmp);
}
Py_DECREF(inner);
return outer;
}
/* still owns a reference to the original object */
- Py_DECREF(o);
- o = res;
+ Py_SETREF(o, res);
}
if (is_unicode) {