Skip to content

Conversation

@radarhere
Copy link
Member

When splitting an image into multiple bands,

Pillow/src/_imaging.c

Lines 2473 to 2484 in b33a315

for (i = 0; i < self->image->bands; i++) {
imaging_object = PyImagingNew(bands[i]);
if (!imaging_object) {
fails += 1;
}
PyTuple_SET_ITEM(list, i, imaging_object);
}
if (fails) {
Py_DECREF(list);
list = NULL;
}
return list;

rather than counting failures and continuing, it would simpler to break immediately on failure.

@hugovk hugovk changed the title Simplified code Simplify code Jan 2, 2026
@hugovk hugovk changed the title Simplify code Simplify band-splitting Jan 2, 2026
@hugovk hugovk changed the title Simplify band-splitting Simplify band splitting Jan 2, 2026
@hugovk hugovk merged commit c9ac097 into python-pillow:main Jan 2, 2026
51 of 53 checks passed
@radarhere radarhere deleted the split branch January 2, 2026 05:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants