From 4051426f6302df48d86cfc8e8282a77d2621db19 Mon Sep 17 00:00:00 2001 From: Hai Shi Date: Sun, 3 May 2020 20:25:52 +0800 Subject: [PATCH] Use Py_IS_TYPE to check for types --- Objects/genericaliasobject.c | 4 ++-- Objects/typeobject.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Objects/genericaliasobject.c b/Objects/genericaliasobject.c index a56bdda38177f4..cc2471cb1109b8 100644 --- a/Objects/genericaliasobject.c +++ b/Objects/genericaliasobject.c @@ -339,8 +339,8 @@ ga_getattro(PyObject *self, PyObject *name) static PyObject * ga_richcompare(PyObject *a, PyObject *b, int op) { - if (Py_TYPE(a) != &Py_GenericAliasType || - Py_TYPE(b) != &Py_GenericAliasType || + if (!Py_IS_TYPE(a, &Py_GenericAliasType) || + !Py_IS_TYPE(b, &Py_GenericAliasType) || (op != Py_EQ && op != Py_NE)) { Py_RETURN_NOTIMPLEMENTED; diff --git a/Objects/typeobject.c b/Objects/typeobject.c index c2ddc162ac82c4..db0ae970090ba9 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -6306,7 +6306,7 @@ FUNCNAME(PyObject *self, PyObject *other) \ stack[1] = other; \ r = vectorcall_maybe(tstate, &op_id, stack, 2); \ if (r != Py_NotImplemented || \ - Py_TYPE(other) == Py_TYPE(self)) \ + Py_IS_TYPE(other, Py_TYPE(self))) \ return r; \ Py_DECREF(r); \ } \