Skip to content

Remove mode and size checks from C transpose methods - #9962

Open
radarhere wants to merge 1 commit into
python-pillow:mainfrom
radarhere:geometry
Open

Remove mode and size checks from C transpose methods#9962
radarhere wants to merge 1 commit into
python-pillow:mainfrom
radarhere:geometry

Conversation

@radarhere

Copy link
Copy Markdown
Member

Given that _transpose sets imOut from imIn properties

imOut = ImagingNewDirty(imIn->mode, imIn->xsize, imIn->ysize);

I don't think that subsequent functions need to check the mode and size.

#9785 is an alternative that goes in the opposite direction, checking the return values and cleaning up on failure.

@akx akx left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite like this, because the loops just below assume that these preconditions hold.

@radarhere

Copy link
Copy Markdown
Member Author

I'm aware there's a difference of opinion here. We'll see what another reviewer thinks.

@akx

akx commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Also, per #9785 (comment) functions like ImagingTranspose and ImagingHorizontalBoxBlur are used by other Pillow functions, not only the Python interface _transpose...

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