diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-12-24 10:39:57 +0200 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-12-24 10:39:57 +0200 |
commit | f0069403518243e37da0aaaa1148d9dfee1adebd (patch) | |
tree | c6fc0eb9f3dc2b917e2f998cb25e59248453d49d /Objects/typeobject.c | |
parent | 2bd58e39918d83c639366c69a4da247238f8183f (diff) | |
parent | 5a57ade58ec5bee85db41b8ce1340ff077781b65 (diff) | |
download | cpython-git-f0069403518243e37da0aaaa1148d9dfee1adebd.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.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 934933026e..341e18c455 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; } @@ -2918,8 +2916,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; } |