diff --git a/src/_imaging.c b/src/_imaging.c index e1284501d..f7f8b64c4 100644 --- a/src/_imaging.c +++ b/src/_imaging.c @@ -3862,7 +3862,11 @@ image_richcompare(const ImagingObject *self, const PyObject *other, const int op // If the other object is not an ImagingObject. if (!PyImaging_Check(other)) { - return op == Py_EQ ? Py_False : Py_True; + if (op == Py_EQ) { + Py_RETURN_FALSE; + } else { + Py_RETURN_TRUE; + } } const Imaging img_a = self->image; @@ -3881,7 +3885,11 @@ image_richcompare(const ImagingObject *self, const PyObject *other, const int op || img_a->xsize != img_b->xsize || img_a->ysize != img_b->ysize ) { - return op == Py_EQ ? Py_False : Py_True; + if (op == Py_EQ) { + Py_RETURN_FALSE; + } else { + Py_RETURN_TRUE; + } } const ImagingPalette palette_a = img_a->palette; @@ -3911,7 +3919,11 @@ image_richcompare(const ImagingObject *self, const PyObject *other, const int op palette_b_data_ptr ) ) { - return op == Py_EQ ? Py_False : Py_True; + if (op == Py_EQ) { + Py_RETURN_FALSE; + } else { + Py_RETURN_TRUE; + } } } @@ -3930,11 +3942,17 @@ image_richcompare(const ImagingObject *self, const PyObject *other, const int op (const UINT8 **)img_b->image ) ) { - PyErr_Clear(); - return op == Py_EQ ? Py_False : Py_True; + if (op == Py_EQ) { + Py_RETURN_FALSE; + } else { + Py_RETURN_TRUE; + } } else { - PyErr_Clear(); - return op == Py_EQ ? Py_True : Py_False; + if (op == Py_EQ) { + Py_RETURN_TRUE; + } else { + Py_RETURN_FALSE; + } } }