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/complexobject.c b/Objects/complexobject.c
index f1b7667..8d1461b 100644
--- a/Objects/complexobject.c
+++ b/Objects/complexobject.c
@@ -296,7 +296,7 @@
if (!PyComplex_Check(res)) {
PyErr_Format(PyExc_TypeError,
"__complex__ returned non-complex (type %.200s)",
- res->ob_type->tp_name);
+ Py_TYPE(res)->tp_name);
Py_DECREF(res);
return NULL;
}
@@ -305,7 +305,7 @@
"__complex__ returned non-complex (type %.200s). "
"The ability to return an instance of a strict subclass of complex "
"is deprecated, and may be removed in a future version of Python.",
- res->ob_type->tp_name)) {
+ Py_TYPE(res)->tp_name)) {
Py_DECREF(res);
return NULL;
}
@@ -958,7 +958,7 @@
return NULL;
}
- nbr = r->ob_type->tp_as_number;
+ nbr = Py_TYPE(r)->tp_as_number;
if (nbr == NULL || (nbr->nb_float == NULL && nbr->nb_index == NULL)) {
PyErr_Format(PyExc_TypeError,
"complex() first argument must be a string or a number, "
@@ -970,7 +970,7 @@
return NULL;
}
if (i != NULL) {
- nbi = i->ob_type->tp_as_number;
+ nbi = Py_TYPE(i)->tp_as_number;
if (nbi == NULL || (nbi->nb_float == NULL && nbi->nb_index == NULL)) {
PyErr_Format(PyExc_TypeError,
"complex() second argument must be a number, "