bpo-39573: Use Py_IS_TYPE to check for types (GH-19882) · python/cpython@5e8ffe1 (original) (raw)

2 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -424,8 +424,8 @@ ga_getattro(PyObject *self, PyObject *name)
424 424 static PyObject *
425 425 ga_richcompare(PyObject *a, PyObject *b, int op)
426 426 {
427 -if (Py_TYPE(a) != &Py_GenericAliasType |
428 -Py_TYPE(b) != &Py_GenericAliasType |
427 +if (!Py_IS_TYPE(a, &Py_GenericAliasType) |
428 +!Py_IS_TYPE(b, &Py_GenericAliasType) |
429 429 (op != Py_EQ && op != Py_NE))
430 430 {
431 431 Py_RETURN_NOTIMPLEMENTED;
Original file line number Diff line number Diff line change
@@ -6306,7 +6306,7 @@ FUNCNAME(PyObject *self, PyObject *other) \
6306 6306 stack[1] = other; \
6307 6307 r = vectorcall_maybe(tstate, &op_id, stack, 2); \
6308 6308 if (r != Py_NotImplemented |
6309 -Py_TYPE(other) == Py_TYPE(self)) \
6309 +Py_IS_TYPE(other, Py_TYPE(self))) \
6310 6310 return r; \
6311 6311 Py_DECREF(r); \
6312 6312 } \