summaryrefslogtreecommitdiff
path: root/Objects/typeobject.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-12-24 10:35:59 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2015-12-24 10:35:59 +0200
commit5a57ade58ec5bee85db41b8ce1340ff077781b65 (patch)
tree2f8cf61efba46284b2d4437916bc3469d23c0ce3 /Objects/typeobject.c
parenta198645fa0f9a9c6183c211955083765dc8ab3a8 (diff)
downloadcpython-git-5a57ade58ec5bee85db41b8ce1340ff077781b65.tar.gz
Issue #20440: Massive replacing unsafe attribute setting code with special
macro Py_SETREF.
Diffstat (limited to 'Objects/typeobject.c')
-rw-r--r--Objects/typeobject.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 0b94fc5263..5b858bde03 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;
}