mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
Issue #26200: Added Py_SETREF and replaced Py_XSETREF with Py_SETREF
in places where Py_DECREF was used.
This commit is contained in:
commit
f01e408c16
23 changed files with 58 additions and 48 deletions
|
@ -3697,7 +3697,7 @@ PyBytes_Concat(PyObject **pv, PyObject *w)
|
|||
/* Multiple references, need to create new object */
|
||||
PyObject *v;
|
||||
v = bytes_concat(*pv, w);
|
||||
Py_XSETREF(*pv, v);
|
||||
Py_SETREF(*pv, v);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -504,7 +504,7 @@ func_new(PyTypeObject* type, PyObject* args, PyObject* kw)
|
|||
|
||||
if (name != Py_None) {
|
||||
Py_INCREF(name);
|
||||
Py_XSETREF(newfunc->func_name, name);
|
||||
Py_SETREF(newfunc->func_name, name);
|
||||
}
|
||||
if (defaults != Py_None) {
|
||||
Py_INCREF(defaults);
|
||||
|
|
|
@ -735,7 +735,7 @@ list_ass_item(PyListObject *a, Py_ssize_t i, PyObject *v)
|
|||
if (v == NULL)
|
||||
return list_ass_slice(a, i, i+1, v);
|
||||
Py_INCREF(v);
|
||||
Py_XSETREF(a->ob_item[i], v);
|
||||
Py_SETREF(a->ob_item[i], v);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1064,7 +1064,7 @@ longrangeiter_next(longrangeiterobject *r)
|
|||
result = PyNumber_Add(r->start, product);
|
||||
Py_DECREF(product);
|
||||
if (result) {
|
||||
Py_XSETREF(r->index, new_index);
|
||||
Py_SETREF(r->index, new_index);
|
||||
}
|
||||
else {
|
||||
Py_DECREF(new_index);
|
||||
|
|
|
@ -424,7 +424,7 @@ type_set_name(PyTypeObject *type, PyObject *value, void *context)
|
|||
|
||||
type->tp_name = tp_name;
|
||||
Py_INCREF(value);
|
||||
Py_XSETREF(((PyHeapTypeObject*)type)->ht_name, value);
|
||||
Py_SETREF(((PyHeapTypeObject*)type)->ht_name, value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -445,7 +445,7 @@ type_set_qualname(PyTypeObject *type, PyObject *value, void *context)
|
|||
|
||||
et = (PyHeapTypeObject*)type;
|
||||
Py_INCREF(value);
|
||||
Py_XSETREF(et->ht_qualname, value);
|
||||
Py_SETREF(et->ht_qualname, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2903,7 +2903,7 @@ _PyType_Lookup(PyTypeObject *type, PyObject *name)
|
|||
else
|
||||
method_cache_misses++;
|
||||
#endif
|
||||
Py_XSETREF(method_cache[h].name, name);
|
||||
Py_SETREF(method_cache[h].name, name);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -1830,7 +1830,7 @@ unicode_resize(PyObject **p_unicode, Py_ssize_t length)
|
|||
_Py_INCREF_UNICODE_EMPTY();
|
||||
if (!unicode_empty)
|
||||
return -1;
|
||||
Py_XSETREF(*p_unicode, unicode_empty);
|
||||
Py_SETREF(*p_unicode, unicode_empty);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1838,7 +1838,7 @@ unicode_resize(PyObject **p_unicode, Py_ssize_t length)
|
|||
PyObject *copy = resize_copy(unicode, length);
|
||||
if (copy == NULL)
|
||||
return -1;
|
||||
Py_XSETREF(*p_unicode, copy);
|
||||
Py_SETREF(*p_unicode, copy);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -13547,7 +13547,7 @@ _PyUnicodeWriter_PrepareInternal(_PyUnicodeWriter *writer,
|
|||
return -1;
|
||||
_PyUnicode_FastCopyCharacters(newbuffer, 0,
|
||||
writer->buffer, 0, writer->pos);
|
||||
Py_XSETREF(writer->buffer, newbuffer);
|
||||
Py_SETREF(writer->buffer, newbuffer);
|
||||
}
|
||||
_PyUnicodeWriter_Update(writer);
|
||||
return 0;
|
||||
|
@ -15264,7 +15264,7 @@ PyUnicode_InternInPlace(PyObject **p)
|
|||
|
||||
if (t) {
|
||||
Py_INCREF(t);
|
||||
Py_XSETREF(*p, t);
|
||||
Py_SETREF(*p, t);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue