Skip to content

Commit c9ac097

Browse files
authored
Simplify band splitting (#9291)
2 parents 3baedf2 + 921a470 commit c9ac097

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/_imaging.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2459,7 +2459,6 @@ _merge(PyObject *self, PyObject *args) {
24592459

24602460
static PyObject *
24612461
_split(ImagingObject *self) {
2462-
int fails = 0;
24632462
Py_ssize_t i;
24642463
PyObject *list;
24652464
PyObject *imaging_object;
@@ -2473,14 +2472,12 @@ _split(ImagingObject *self) {
24732472
for (i = 0; i < self->image->bands; i++) {
24742473
imaging_object = PyImagingNew(bands[i]);
24752474
if (!imaging_object) {
2476-
fails += 1;
2475+
Py_DECREF(list);
2476+
list = NULL;
2477+
break;
24772478
}
24782479
PyTuple_SET_ITEM(list, i, imaging_object);
24792480
}
2480-
if (fails) {
2481-
Py_DECREF(list);
2482-
list = NULL;
2483-
}
24842481
return list;
24852482
}
24862483

0 commit comments

Comments
 (0)