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

@ -2633,7 +2633,7 @@ main_loop:
PyObject *none_val = _PyList_Extend((PyListObject *)list, iterable);
if (none_val == NULL) {
if (_PyErr_ExceptionMatches(tstate, PyExc_TypeError) &&
(iterable->ob_type->tp_iter == NULL && !PySequence_Check(iterable)))
(Py_TYPE(iterable)->tp_iter == NULL && !PySequence_Check(iterable)))
{
_PyErr_Clear(tstate);
_PyErr_Format(tstate, PyExc_TypeError,
@ -2803,7 +2803,7 @@ main_loop:
if (_PyErr_ExceptionMatches(tstate, PyExc_AttributeError)) {
_PyErr_Format(tstate, PyExc_TypeError,
"'%.200s' object is not a mapping",
update->ob_type->tp_name);
Py_TYPE(update)->tp_name);
}
Py_DECREF(update);
goto error;
@ -3158,7 +3158,7 @@ main_loop:
PREDICTED(FOR_ITER);
/* before: [iter]; after: [iter, iter()] *or* [] */
PyObject *iter = TOP();
PyObject *next = (*iter->ob_type->tp_iternext)(iter);
PyObject *next = (*Py_TYPE(iter)->tp_iternext)(iter);
if (next != NULL) {
PUSH(next);
PREDICT(STORE_FAST);
@ -4369,11 +4369,11 @@ unpack_iterable(PyThreadState *tstate, PyObject *v,
it = PyObject_GetIter(v);
if (it == NULL) {
if (_PyErr_ExceptionMatches(tstate, PyExc_TypeError) &&
v->ob_type->tp_iter == NULL && !PySequence_Check(v))
Py_TYPE(v)->tp_iter == NULL && !PySequence_Check(v))
{
_PyErr_Format(tstate, PyExc_TypeError,
"cannot unpack non-iterable %.200s object",
v->ob_type->tp_name);
Py_TYPE(v)->tp_name);
}
return 0;
}
@ -4790,7 +4790,7 @@ PyEval_GetFuncName(PyObject *func)
else if (PyCFunction_Check(func))
return ((PyCFunctionObject*)func)->m_ml->ml_name;
else
return func->ob_type->tp_name;
return Py_TYPE(func)->tp_name;
}
const char *
@ -5197,7 +5197,7 @@ import_all_from(PyThreadState *tstate, PyObject *locals, PyObject *v)
static int
check_args_iterable(PyThreadState *tstate, PyObject *func, PyObject *args)
{
if (args->ob_type->tp_iter == NULL && !PySequence_Check(args)) {
if (Py_TYPE(args)->tp_iter == NULL && !PySequence_Check(args)) {
/* check_args_iterable() may be called with a live exception:
* clear it to prevent calling _PyObject_FunctionStr() with an
* exception set. */