bpo-39573: Use Py_TYPE() macro in Objects directory (GH-18392)
Replace direct access to PyObject.ob_type with Py_TYPE().
diff --git a/Objects/descrobject.c b/Objects/descrobject.c
index b9b16d6d..49c26eb 100644
--- a/Objects/descrobject.c
+++ b/Objects/descrobject.c
@@ -84,7 +84,7 @@
"doesn't apply to a '%.100s' object",
descr_name((PyDescrObject *)descr), "?",
descr->d_type->tp_name,
- obj->ob_type->tp_name);
+ Py_TYPE(obj)->tp_name);
*pres = NULL;
return 1;
}
@@ -97,7 +97,7 @@
/* Ensure a valid type. Class methods ignore obj. */
if (type == NULL) {
if (obj != NULL)
- type = (PyObject *)obj->ob_type;
+ type = (PyObject *)Py_TYPE(obj);
else {
/* Wot - no type?! */
PyErr_Format(PyExc_TypeError,
@@ -114,7 +114,7 @@
"needs a type, not a '%.100s' as arg 2",
descr_name((PyDescrObject *)descr), "?",
PyDescr_TYPE(descr)->tp_name,
- type->ob_type->tp_name);
+ Py_TYPE(type)->tp_name);
return NULL;
}
if (!PyType_IsSubtype((PyTypeObject *)type, PyDescr_TYPE(descr))) {
@@ -194,7 +194,7 @@
"doesn't apply to a '%.100s' object",
descr_name(descr), "?",
descr->d_type->tp_name,
- obj->ob_type->tp_name);
+ Py_TYPE(obj)->tp_name);
*pres = -1;
return 1;
}
@@ -506,7 +506,7 @@
"but received a '%.100s'",
descr_name((PyDescrObject *)descr), "?",
PyDescr_TYPE(descr)->tp_name,
- self->ob_type->tp_name);
+ Py_TYPE(self)->tp_name);
return NULL;
}
@@ -1234,7 +1234,7 @@
{
return PyUnicode_FromFormat("<method-wrapper '%s' of %s object at %p>",
wp->descr->d_base->name,
- wp->self->ob_type->tp_name,
+ Py_TYPE(wp->self)->tp_name,
wp->self);
}
@@ -1476,7 +1476,7 @@
Py_XDECREF(gs->prop_set);
Py_XDECREF(gs->prop_del);
Py_XDECREF(gs->prop_doc);
- self->ob_type->tp_free(self);
+ Py_TYPE(self)->tp_free(self);
}
static PyObject *