summaryrefslogtreecommitdiff
path: root/Objects/typeobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/typeobject.c')
-rw-r--r--Objects/typeobject.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 5b8d5a228e..e6a84b017a 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -4097,9 +4097,10 @@ object_set_class(PyObject *self, PyObject *value, void *closure)
}
if (compatible_for_assignment(oldto, newto, "__class__")) {
- if (newto->tp_flags & Py_TPFLAGS_HEAPTYPE)
+ if (newto->tp_flags & Py_TPFLAGS_HEAPTYPE) {
Py_INCREF(newto);
- Py_TYPE(self) = newto;
+ }
+ Py_SET_TYPE(self, newto);
if (oldto->tp_flags & Py_TPFLAGS_HEAPTYPE)
Py_DECREF(oldto);
return 0;
@@ -5334,8 +5335,9 @@ PyType_Ready(PyTypeObject *type)
NULL when type is &PyBaseObject_Type, and we know its ob_type is
not NULL (it's initialized to &PyType_Type). But coverity doesn't
know that. */
- if (Py_TYPE(type) == NULL && base != NULL)
- Py_TYPE(type) = Py_TYPE(base);
+ if (Py_TYPE(type) == NULL && base != NULL) {
+ Py_SET_TYPE(type, Py_TYPE(base));
+ }
/* Initialize tp_bases */
bases = type->tp_bases;