diff options
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/bytesobject.c | 3 | ||||
-rw-r--r-- | Objects/descrobject.c | 3 | ||||
-rw-r--r-- | Objects/exceptions.c | 3 | ||||
-rw-r--r-- | Objects/frameobject.c | 3 | ||||
-rw-r--r-- | Objects/funcobject.c | 15 | ||||
-rw-r--r-- | Objects/moduleobject.c | 3 | ||||
-rw-r--r-- | Objects/rangeobject.c | 3 | ||||
-rw-r--r-- | Objects/typeobject.c | 9 | ||||
-rw-r--r-- | Objects/unicodeobject.c | 12 |
9 files changed, 18 insertions, 36 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index d8fb96b..51d0871 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -3520,8 +3520,7 @@ PyBytes_Concat(PyObject **pv, PyObject *w) /* Multiple references, need to create new object */ PyObject *v; v = bytes_concat(*pv, w); - Py_DECREF(*pv); - *pv = v; + Py_SETREF(*pv, v); } } diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 9ffbca7..da11f6b 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1509,8 +1509,7 @@ property_init(PyObject *self, PyObject *args, PyObject *kwds) PyObject *get_doc = _PyObject_GetAttrId(get, &PyId___doc__); if (get_doc) { if (Py_TYPE(self) == &PyProperty_Type) { - Py_XDECREF(prop->prop_doc); - prop->prop_doc = get_doc; + Py_SETREF(prop->prop_doc, get_doc); } else { /* If this is a property subclass, put __doc__ diff --git a/Objects/exceptions.c b/Objects/exceptions.c index f5a1a2b..62ea378 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -236,8 +236,7 @@ BaseException_set_tb(PyBaseExceptionObject *self, PyObject *tb) } Py_XINCREF(tb); - Py_XDECREF(self->traceback); - self->traceback = tb; + Py_SETREF(self->traceback, tb); return 0; } diff --git a/Objects/frameobject.c b/Objects/frameobject.c index 172f2cb..37e626d 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -857,8 +857,7 @@ dict_to_map(PyObject *map, Py_ssize_t nmap, PyObject *dict, PyObject **values, } } else if (values[j] != value) { Py_XINCREF(value); - Py_XDECREF(values[j]); - values[j] = value; + Py_SETREF(values[j], value); } Py_XDECREF(value); } diff --git a/Objects/funcobject.c b/Objects/funcobject.c index b043934..13daaba 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -127,8 +127,7 @@ PyFunction_SetDefaults(PyObject *op, PyObject *defaults) PyErr_SetString(PyExc_SystemError, "non-tuple default args"); return -1; } - Py_XDECREF(((PyFunctionObject *) op) -> func_defaults); - ((PyFunctionObject *) op) -> func_defaults = defaults; + Py_SETREF(((PyFunctionObject *)op)->func_defaults, defaults); return 0; } @@ -159,8 +158,7 @@ PyFunction_SetKwDefaults(PyObject *op, PyObject *defaults) "non-dict keyword only default args"); return -1; } - Py_XDECREF(((PyFunctionObject *)op) -> func_kwdefaults); - ((PyFunctionObject *) op) -> func_kwdefaults = defaults; + Py_SETREF(((PyFunctionObject *)op)->func_kwdefaults, defaults); return 0; } @@ -192,8 +190,7 @@ PyFunction_SetClosure(PyObject *op, PyObject *closure) closure->ob_type->tp_name); return -1; } - Py_XDECREF(((PyFunctionObject *) op) -> func_closure); - ((PyFunctionObject *) op) -> func_closure = closure; + Py_SETREF(((PyFunctionObject *)op)->func_closure, closure); return 0; } @@ -224,8 +221,7 @@ PyFunction_SetAnnotations(PyObject *op, PyObject *annotations) "non-dict annotations"); return -1; } - Py_XDECREF(((PyFunctionObject *)op) -> func_annotations); - ((PyFunctionObject *) op) -> func_annotations = annotations; + Py_SETREF(((PyFunctionObject *)op)->func_annotations, annotations); return 0; } @@ -531,8 +527,7 @@ func_new(PyTypeObject* type, PyObject* args, PyObject* kw) if (name != Py_None) { Py_INCREF(name); - Py_DECREF(newfunc->func_name); - newfunc->func_name = name; + Py_SETREF(newfunc->func_name, name); } if (defaults != Py_None) { Py_INCREF(defaults); diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c index 7b41b0b..24c5f4c 100644 --- a/Objects/moduleobject.c +++ b/Objects/moduleobject.c @@ -69,8 +69,7 @@ module_init_dict(PyModuleObject *mod, PyObject *md_dict, return -1; if (PyUnicode_CheckExact(name)) { Py_INCREF(name); - Py_XDECREF(mod->md_name); - mod->md_name = name; + Py_SETREF(mod->md_name, name); } return 0; diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c index da1d703..f858cd2 100644 --- a/Objects/rangeobject.c +++ b/Objects/rangeobject.c @@ -1066,8 +1066,7 @@ longrangeiter_next(longrangeiterobject *r) result = PyNumber_Add(r->start, product); Py_DECREF(product); if (result) { - Py_DECREF(r->index); - r->index = new_index; + Py_SETREF(r->index, new_index); } else { Py_DECREF(new_index); diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 0b94fc5..5b858bd 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -315,9 +315,8 @@ assign_version_tag(PyTypeObject *type) are borrowed reference */ for (i = 0; i < (1 << MCACHE_SIZE_EXP); i++) { method_cache[i].value = NULL; - Py_XDECREF(method_cache[i].name); - method_cache[i].name = Py_None; Py_INCREF(Py_None); + Py_SETREF(method_cache[i].name, Py_None); } /* mark all version tags as invalid */ PyType_Modified(&PyBaseObject_Type); @@ -462,8 +461,7 @@ type_set_qualname(PyTypeObject *type, PyObject *value, void *context) et = (PyHeapTypeObject*)type; Py_INCREF(value); - Py_DECREF(et->ht_qualname); - et->ht_qualname = value; + Py_SETREF(et->ht_qualname, value); return 0; } @@ -2910,8 +2908,7 @@ _PyType_Lookup(PyTypeObject *type, PyObject *name) else method_cache_misses++; #endif - Py_DECREF(method_cache[h].name); - method_cache[h].name = name; + Py_SETREF(method_cache[h].name, name); } return res; } diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 0b78301..c5b35e1 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -1665,8 +1665,7 @@ unicode_resize(PyObject **p_unicode, Py_ssize_t length) _Py_INCREF_UNICODE_EMPTY(); if (!unicode_empty) return -1; - Py_DECREF(*p_unicode); - *p_unicode = unicode_empty; + Py_SETREF(*p_unicode, unicode_empty); return 0; } @@ -1674,8 +1673,7 @@ unicode_resize(PyObject **p_unicode, Py_ssize_t length) PyObject *copy = resize_copy(unicode, length); if (copy == NULL) return -1; - Py_DECREF(*p_unicode); - *p_unicode = copy; + Py_SETREF(*p_unicode, copy); return 0; } @@ -13322,8 +13320,7 @@ _PyUnicodeWriter_PrepareInternal(_PyUnicodeWriter *writer, return -1; _PyUnicode_FastCopyCharacters(newbuffer, 0, writer->buffer, 0, writer->pos); - Py_DECREF(writer->buffer); - writer->buffer = newbuffer; + Py_SETREF(writer->buffer, newbuffer); } _PyUnicodeWriter_Update(writer); return 0; @@ -15009,8 +15006,7 @@ PyUnicode_InternInPlace(PyObject **p) if (t) { Py_INCREF(t); - Py_DECREF(*p); - *p = t; + Py_SETREF(*p, t); return; } |