bpo-39573: Use Py_TYPE() macro in Python and Include directories (GH-… · python/cpython@a102ed7

@@ -170,7 +170,7 @@ builtin___build_class__(PyObject *self, PyObject *const *args, Py_ssize_t nargs,

170170

/* else get the type of the first base */

171171

else {

172172

PyObject *base0 = PyTuple_GET_ITEM(bases, 0);

173-

meta = (PyObject *) (base0->ob_type);

173+

meta = (PyObject *)Py_TYPE(base0);

174174

}

175175

Py_INCREF(meta);

176176

isclass = 1; /* meta is really a class */

@@ -1002,13 +1002,13 @@ builtin_exec_impl(PyObject *module, PyObject *source, PyObject *globals,

1002100210031003

if (!PyDict_Check(globals)) {

10041004

PyErr_Format(PyExc_TypeError, "exec() globals must be a dict, not %.100s",

1005-

globals->ob_type->tp_name);

1005+

Py_TYPE(globals)->tp_name);

10061006

return NULL;

10071007

}

10081008

if (!PyMapping_Check(locals)) {

10091009

PyErr_Format(PyExc_TypeError,

10101010

"locals must be a mapping or None, not %.100s",

1011-

locals->ob_type->tp_name);

1011+

Py_TYPE(locals)->tp_name);

10121012

return NULL;

10131013

}

10141014

if (_PyDict_GetItemIdWithError(globals, &PyId___builtins__) == NULL) {

@@ -1383,11 +1383,11 @@ builtin_next(PyObject *self, PyObject *const *args, Py_ssize_t nargs)

13831383

if (!PyIter_Check(it)) {

13841384

PyErr_Format(PyExc_TypeError,

13851385

"'%.200s' object is not an iterator",

1386-

it->ob_type->tp_name);

1386+

Py_TYPE(it)->tp_name);

13871387

return NULL;

13881388

}

138913891390-

res = (*it->ob_type->tp_iternext)(it);

1390+

res = (*Py_TYPE(it)->tp_iternext)(it);

13911391

if (res != NULL) {

13921392

return res;

13931393

} else if (nargs > 1) {

@@ -1788,7 +1788,7 @@ builtin_ord(PyObject *module, PyObject *c)

17881788

else {

17891789

PyErr_Format(PyExc_TypeError,

17901790

"ord() expected string of length 1, but " \

1791-

"%.200s found", c->ob_type->tp_name);

1791+

"%.200s found", Py_TYPE(c)->tp_name);

17921792

return NULL;

17931793

}

17941794

@@ -1856,7 +1856,7 @@ builtin_print(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject

18561856

else if (sep && !PyUnicode_Check(sep)) {

18571857

PyErr_Format(PyExc_TypeError,

18581858

"sep must be None or a string, not %.200s",

1859-

sep->ob_type->tp_name);

1859+

Py_TYPE(sep)->tp_name);

18601860

return NULL;

18611861

}

18621862

if (end == Py_None) {

@@ -1865,7 +1865,7 @@ builtin_print(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject

18651865

else if (end && !PyUnicode_Check(end)) {

18661866

PyErr_Format(PyExc_TypeError,

18671867

"end must be None or a string, not %.200s",

1868-

end->ob_type->tp_name);

1868+

Py_TYPE(end)->tp_name);

18691869

return NULL;

18701870

}

18711871