changed = 1;
}
if (!changed && PyBytes_CheckExact(input_obj)) {
- Py_INCREF(input_obj);
- Py_DECREF(result);
- result = input_obj;
+ Py_SETREF(result, Py_NewRef(input_obj));
}
PyBuffer_Release(&del_table_view);
PyBuffer_Release(&table_view);
}
} else {
PyObject *object2 = PyObject_GetAttrString(object, trace);
- Py_DECREF(object);
- object = object2;
+ Py_SETREF(object, object2);
}
if (!object) {
goto EXIT;
else {
PyObject *v;
v = PyBytes_FromStringAndSize(s, len-1);
- Py_DECREF(result);
- result = v;
+ Py_SETREF(result, v);
}
}
}
else if (PyUnicode_READ_CHAR(result, len-1) == '\n') {
PyObject *v;
v = PyUnicode_Substring(result, 0, len-1);
- Py_DECREF(result);
- result = v;
+ Py_SETREF(result, v);
}
}
return result;
temp = _PyLong_Lshift(ww, 1);
if (temp == NULL)
goto Error;
- Py_DECREF(ww);
- ww = temp;
+ Py_SETREF(ww, temp);
temp = _PyLong_Lshift(vv, 1);
if (temp == NULL)
goto Error;
- Py_DECREF(vv);
- vv = temp;
+ Py_SETREF(vv, temp);
temp = PyNumber_Or(vv, _PyLong_GetOne());
if (temp == NULL)
goto Error;
- Py_DECREF(vv);
- vv = temp;
+ Py_SETREF(vv, temp);
}
r = PyObject_RichCompareBool(vv, ww, op);
}
else {
/* Normalize to raise <class>, <instance> */
- Py_XDECREF(val);
- val = typ;
+ Py_XSETREF(val, typ);
typ = Py_NewRef(PyExceptionInstance_Class(typ));
if (tb == NULL)
Py_DECREF(result);
return NULL;
}
- Py_DECREF(result);
- result = newresult;
+ Py_SETREF(result, newresult);
}
return result;
}
if (_PyLong_Sign(start) < 0) {
/* start += length */
PyObject *tmp = PyNumber_Add(start, length);
- Py_DECREF(start);
- start = tmp;
+ Py_SETREF(start, tmp);
if (start == NULL)
goto error;
if (cmp_result < 0)
goto error;
if (cmp_result) {
- Py_INCREF(lower);
- Py_DECREF(start);
- start = lower;
+ Py_SETREF(start, Py_NewRef(lower));
}
}
else {
if (cmp_result < 0)
goto error;
if (cmp_result) {
- Py_INCREF(upper);
- Py_DECREF(start);
- start = upper;
+ Py_SETREF(start, Py_NewRef(upper));
}
}
}
if (_PyLong_Sign(stop) < 0) {
/* stop += length */
PyObject *tmp = PyNumber_Add(stop, length);
- Py_DECREF(stop);
- stop = tmp;
+ Py_SETREF(stop, tmp);
if (stop == NULL)
goto error;
if (cmp_result < 0)
goto error;
if (cmp_result) {
- Py_INCREF(lower);
- Py_DECREF(stop);
- stop = lower;
+ Py_SETREF(stop, Py_NewRef(lower));
}
}
else {
if (cmp_result < 0)
goto error;
if (cmp_result) {
- Py_INCREF(upper);
- Py_DECREF(stop);
- stop = upper;
+ Py_SETREF(stop, Py_NewRef(upper));
}
}
}
goto error;
/* assign to obj */
- Py_DECREF(obj);
- obj = tmp;
+ Py_SETREF(obj, tmp);
}
/* end of iterator, this is the non-error case */
if (ok == 1)
goto done;
/* do the assignment, transferring ownership: fieldobj = tmp */
- Py_DECREF(fieldobj);
- fieldobj = tmp;
+ Py_SETREF(fieldobj, tmp);
tmp = NULL;
}
else {
/* Copy __dict__ to avoid mutating it. */
PyObject *temp = PyDict_Copy(dict);
- Py_DECREF(dict);
- dict = temp;
+ Py_SETREF(dict, temp);
}
if (dict == NULL)
(See SF ID #743627) */
(su->obj == (PyObject *)starttype) ? NULL : su->obj,
(PyObject *)starttype);
- Py_DECREF(res);
- res = res2;
+ Py_SETREF(res, res2);
}
Py_DECREF(mro);
for (i = 0; i < numdigits; i++)
*b1++ = *buf++;
*b1 = '\0';
- Py_DECREF(result);
- result = r1;
+ Py_SETREF(result, r1);
buf = PyBytes_AS_STRING(result);
len = numnondigits + prec;
}
|| buf != PyUnicode_DATA(result)) {
PyObject *unicode;
unicode = _PyUnicode_FromASCII(buf, len);
- Py_DECREF(result);
- result = unicode;
+ Py_SETREF(result, unicode);
}
else if (len != PyUnicode_GET_LENGTH(result)) {
if (PyUnicode_Resize(&result, len) < 0)
during GC. Return that one instead of this one
to avoid violating the invariants of the list
of weakrefs for ob. */
- Py_DECREF(result);
- result = (PyWeakReference*)Py_NewRef(ref);
+ Py_SETREF(result, (PyWeakReference*)Py_NewRef(ref));
}
}
else {
during GC. Return that one instead of this one
to avoid violating the invariants of the list
of weakrefs for ob. */
- Py_DECREF(result);
- result = (PyWeakReference*)Py_NewRef(proxy);
+ Py_SETREF(result, (PyWeakReference*)Py_NewRef(proxy));
goto skip_insert;
}
prev = ref;
{
do {
PyFrameObject *back = PyFrame_GetBack(frame);
- Py_DECREF(frame);
- frame = back;
+ Py_SETREF(frame, back);
} while (frame != NULL && is_internal_frame(frame));
return frame;
if (stack_level <= 0 || is_internal_frame(f)) {
while (--stack_level > 0 && f != NULL) {
PyFrameObject *back = PyFrame_GetBack(f);
- Py_DECREF(f);
- f = back;
+ Py_SETREF(f, back);
}
}
else {
goto error;
}
if (winner != meta) {
- Py_DECREF(meta);
- meta = Py_NewRef(winner);
+ Py_SETREF(meta, Py_NewRef(winner));
}
}
/* else: meta is not a class, so we cannot do the metaclass
t = PyTuple_GET_ITEM(t, 1);
}
- Py_INCREF(t);
- Py_DECREF(*obj);
- *obj = t;
+ Py_SETREF(*obj, Py_NewRef(t));
return 1;
}
if (fixed_value == NULL) {
goto error;
}
- Py_DECREF(value);
- value = fixed_value;
+ Py_SETREF(value, fixed_value);
}
/* If the class of the instance doesn't exactly match the
class of the type, believe the instance.
*/
else if (inclass != type) {
- Py_INCREF(inclass);
- Py_DECREF(type);
- type = inclass;
+ Py_SETREF(type, Py_NewRef(inclass));
}
}
*exc = type;
}
/* Replace the old value with the new value for the our key. */
- Py_DECREF(new_node->c_array[val_idx]);
- new_node->c_array[val_idx] = Py_NewRef(val);
+ Py_SETREF(new_node->c_array[val_idx], Py_NewRef(val));
return (PyHamtNode *)new_node;
/* The error code should be in the `code' attribute. */
PyObject *code = PyObject_GetAttr(value, &_Py_ID(code));
if (code) {
- Py_DECREF(value);
- value = code;
+ Py_SETREF(value, code);
if (value == Py_None)
goto done;
}
eventArgs = _Py_VaBuildValue_SizeT(argFormat, vargs);
if (eventArgs && !PyTuple_Check(eventArgs)) {
PyObject *argTuple = PyTuple_Pack(1, eventArgs);
- Py_DECREF(eventArgs);
- eventArgs = argTuple;
+ Py_SETREF(eventArgs, argTuple);
}
}
else {
cursor = cursor->tb_next;
}
- PyObject *old_next = (PyObject*)self->tb_next;
- self->tb_next = (PyTracebackObject *)Py_XNewRef(new_next);
- Py_XDECREF(old_next);
+ Py_XSETREF(self->tb_next, (PyTracebackObject *)Py_XNewRef(new_next));
return 0;
}
PyObject *truncated;
truncated = PyUnicode_Substring(lineobj, i, PyUnicode_GET_LENGTH(lineobj));
if (truncated) {
- Py_DECREF(lineobj);
- lineobj = truncated;
+ Py_SETREF(lineobj, truncated);
} else {
PyErr_Clear();
}