bpo-39573: Use Py_TYPE() macro in Objects directory (GH-18392) · python/cpython@58ac700

@@ -84,7 +84,7 @@ descr_check(PyDescrObject *descr, PyObject *obj, PyObject **pres)

8484

"doesn't apply to a '%.100s' object",

8585

descr_name((PyDescrObject *)descr), "?",

8686

descr->d_type->tp_name,

87-

obj->ob_type->tp_name);

87+

Py_TYPE(obj)->tp_name);

8888

*pres = NULL;

8989

return 1;

9090

}

@@ -97,7 +97,7 @@ classmethod_get(PyMethodDescrObject *descr, PyObject *obj, PyObject *type)

9797

/* Ensure a valid type. Class methods ignore obj. */

9898

if (type == NULL) {

9999

if (obj != NULL)

100-

type = (PyObject *)obj->ob_type;

100+

type = (PyObject *)Py_TYPE(obj);

101101

else {

102102

/* Wot - no type?! */

103103

PyErr_Format(PyExc_TypeError,

@@ -114,7 +114,7 @@ classmethod_get(PyMethodDescrObject *descr, PyObject *obj, PyObject *type)

114114

"needs a type, not a '%.100s' as arg 2",

115115

descr_name((PyDescrObject *)descr), "?",

116116

PyDescr_TYPE(descr)->tp_name,

117-

type->ob_type->tp_name);

117+

Py_TYPE(type)->tp_name);

118118

return NULL;

119119

}

120120

if (!PyType_IsSubtype((PyTypeObject *)type, PyDescr_TYPE(descr))) {

@@ -194,7 +194,7 @@ descr_setcheck(PyDescrObject *descr, PyObject *obj, PyObject *value,

194194

"doesn't apply to a '%.100s' object",

195195

descr_name(descr), "?",

196196

descr->d_type->tp_name,

197-

obj->ob_type->tp_name);

197+

Py_TYPE(obj)->tp_name);

198198

*pres = -1;

199199

return 1;

200200

}

@@ -506,7 +506,7 @@ wrapperdescr_call(PyWrapperDescrObject *descr, PyObject *args, PyObject *kwds)

506506

"but received a '%.100s'",

507507

descr_name((PyDescrObject *)descr), "?",

508508

PyDescr_TYPE(descr)->tp_name,

509-

self->ob_type->tp_name);

509+

Py_TYPE(self)->tp_name);

510510

return NULL;

511511

}

512512

@@ -1234,7 +1234,7 @@ wrapper_repr(wrapperobject *wp)

12341234

{

12351235

return PyUnicode_FromFormat("<method-wrapper '%s' of %s object at %p>",

12361236

wp->descr->d_base->name,

1237-

wp->self->ob_type->tp_name,

1237+

Py_TYPE(wp->self)->tp_name,

12381238

wp->self);

12391239

}

12401240

@@ -1476,7 +1476,7 @@ property_dealloc(PyObject *self)

14761476

Py_XDECREF(gs->prop_set);

14771477

Py_XDECREF(gs->prop_del);

14781478

Py_XDECREF(gs->prop_doc);

1479-

self->ob_type->tp_free(self);

1479+

Py_TYPE(self)->tp_free(self);

14801480

}

1481148114821482

static PyObject *