bpo-39573: Use Py_TYPE() macro in Python and Include directories (GH-18391)

Replace direct access to PyObject.ob_type with Py_TYPE().
This commit is contained in:
Victor Stinner 2020-02-07 02:24:48 +01:00 committed by GitHub
parent 38aaaaac80
commit a102ed7d2f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 39 additions and 39 deletions

View file

@ -170,7 +170,7 @@ builtin___build_class__(PyObject *self, PyObject *const *args, Py_ssize_t nargs,
/* else get the type of the first base */
else {
PyObject *base0 = PyTuple_GET_ITEM(bases, 0);
meta = (PyObject *) (base0->ob_type);
meta = (PyObject *)Py_TYPE(base0);
}
Py_INCREF(meta);
isclass = 1; /* meta is really a class */
@ -1002,13 +1002,13 @@ builtin_exec_impl(PyObject *module, PyObject *source, PyObject *globals,
if (!PyDict_Check(globals)) {
PyErr_Format(PyExc_TypeError, "exec() globals must be a dict, not %.100s",
globals->ob_type->tp_name);
Py_TYPE(globals)->tp_name);
return NULL;
}
if (!PyMapping_Check(locals)) {
PyErr_Format(PyExc_TypeError,
"locals must be a mapping or None, not %.100s",
locals->ob_type->tp_name);
Py_TYPE(locals)->tp_name);
return NULL;
}
if (_PyDict_GetItemIdWithError(globals, &PyId___builtins__) == NULL) {
@ -1383,11 +1383,11 @@ builtin_next(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
if (!PyIter_Check(it)) {
PyErr_Format(PyExc_TypeError,
"'%.200s' object is not an iterator",
it->ob_type->tp_name);
Py_TYPE(it)->tp_name);
return NULL;
}
res = (*it->ob_type->tp_iternext)(it);
res = (*Py_TYPE(it)->tp_iternext)(it);
if (res != NULL) {
return res;
} else if (nargs > 1) {
@ -1788,7 +1788,7 @@ builtin_ord(PyObject *module, PyObject *c)
else {
PyErr_Format(PyExc_TypeError,
"ord() expected string of length 1, but " \
"%.200s found", c->ob_type->tp_name);
"%.200s found", Py_TYPE(c)->tp_name);
return NULL;
}
@ -1856,7 +1856,7 @@ builtin_print(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject
else if (sep && !PyUnicode_Check(sep)) {
PyErr_Format(PyExc_TypeError,
"sep must be None or a string, not %.200s",
sep->ob_type->tp_name);
Py_TYPE(sep)->tp_name);
return NULL;
}
if (end == Py_None) {
@ -1865,7 +1865,7 @@ builtin_print(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject
else if (end && !PyUnicode_Check(end)) {
PyErr_Format(PyExc_TypeError,
"end must be None or a string, not %.200s",
end->ob_type->tp_name);
Py_TYPE(end)->tp_name);
return NULL;
}