Skip to content

Commit

Permalink
use Py_RETURN_* macros for Py_True/Py_False
Browse files Browse the repository at this point in the history
  • Loading branch information
Yay295 committed Jul 5, 2023
1 parent 8b23215 commit ae1f9e9
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions src/_imaging.c
Original file line number Diff line number Diff line change
Expand Up @@ -3777,7 +3777,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;

Check warning on line 3781 in src/_imaging.c

View check run for this annotation

Codecov / codecov/patch

src/_imaging.c#L3781

Added line #L3781 was not covered by tests
} else {
Py_RETURN_TRUE;

Check warning on line 3783 in src/_imaging.c

View check run for this annotation

Codecov / codecov/patch

src/_imaging.c#L3783

Added line #L3783 was not covered by tests
}
}

const Imaging img_a = self->image;
Expand All @@ -3788,7 +3792,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;

Check warning on line 3796 in src/_imaging.c

View check run for this annotation

Codecov / codecov/patch

src/_imaging.c#L3796

Added line #L3796 was not covered by tests
} else {
Py_RETURN_TRUE;

Check warning on line 3798 in src/_imaging.c

View check run for this annotation

Codecov / codecov/patch

src/_imaging.c#L3798

Added line #L3798 was not covered by tests
}
}

const ImagingPalette palette_a = img_a->palette;
Expand All @@ -3810,20 +3818,34 @@ 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;

Check warning on line 3822 in src/_imaging.c

View check run for this annotation

Codecov / codecov/patch

src/_imaging.c#L3822

Added line #L3822 was not covered by tests
} else {
Py_RETURN_TRUE;

Check warning on line 3824 in src/_imaging.c

View check run for this annotation

Codecov / codecov/patch

src/_imaging.c#L3824

Added line #L3824 was not covered by tests
}
}
}

if (_compare_pixels(
if (
_compare_pixels(
img_a->mode,
img_a->ysize,
img_a->linesize,
(const UINT8 **)img_a->image,
(const UINT8 **)img_b->image)
(const UINT8 **)img_b->image
)
) {
return op == Py_EQ ? Py_False : Py_True;
if (op == Py_EQ) {
Py_RETURN_FALSE;
} else {
Py_RETURN_TRUE;
}
} else {
return op == Py_EQ ? Py_True : Py_False;
if (op == Py_EQ) {
Py_RETURN_TRUE;
} else {
Py_RETURN_FALSE;

Check warning on line 3847 in src/_imaging.c

View check run for this annotation

Codecov / codecov/patch

src/_imaging.c#L3847

Added line #L3847 was not covered by tests
}
}
}

Expand Down

0 comments on commit ae1f9e9

Please sign in to comment.