bpo-39573: Use Py_IS_TYPE() macro to check for types (GH-18809)

Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
Andy Lester 2020-03-06 16:53:17 -06:00 committed by GitHub
parent e59334ebc9
commit 557287075c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 15 additions and 17 deletions

View file

@ -657,7 +657,7 @@ do_richcompare(PyThreadState *tstate, PyObject *v, PyObject *w, int op)
PyObject *res;
int checked_reverse_op = 0;
if (Py_TYPE(v) != Py_TYPE(w) &&
if (!Py_IS_TYPE(v, Py_TYPE(w)) &&
PyType_IsSubtype(Py_TYPE(w), Py_TYPE(v)) &&
(f = Py_TYPE(w)->tp_richcompare) != NULL) {
checked_reverse_op = 1;
@ -1907,7 +1907,7 @@ _Py_GetObjects(PyObject *self, PyObject *args)
return NULL;
for (i = 0; (n == 0 || i < n) && op != &refchain; i++) {
while (op == self || op == args || op == res || op == t ||
(t != NULL && Py_TYPE(op) != (PyTypeObject *) t)) {
(t != NULL && !Py_IS_TYPE(op, (PyTypeObject *) t))) {
op = op->_ob_next;
if (op == &refchain)
return res;