]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-39573: Use Py_IS_TYPE to check for types (GH-19882)
authorHai Shi <shihai1992@gmail.com>
Mon, 4 May 2020 13:31:38 +0000 (21:31 +0800)
committerGitHub <noreply@github.com>
Mon, 4 May 2020 13:31:38 +0000 (22:31 +0900)
Objects/genericaliasobject.c
Objects/typeobject.c

index c06d79c556190b7d022b24b1c81066efb4d3c9b5..4d511a239063ceb67f7c3296fad7d8c8eae2456e 100644 (file)
@@ -424,8 +424,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;
index c2ddc162ac82c4436256bedf442341f830670cab..db0ae970090ba98b47486d0638008ca1d79e00ee 100644 (file)
@@ -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); \
     } \