Skip to content

Raise ValueError instead of asserting on FTEX format count#9805

Open
ritsth wants to merge 1 commit into
python-pillow:mainfrom
ritsth:fix/ftex-assert-format-count
Open

Raise ValueError instead of asserting on FTEX format count#9805
ritsth wants to merge 1 commit into
python-pillow:mainfrom
ritsth:fix/ftex-assert-format-count

Conversation

@ritsth

@ritsth ritsth commented Jul 21, 2026

Copy link
Copy Markdown

FtexImageFile._open used assert format_count == 1 to reject multi-format files. That raises AssertionError, which is not one of the exceptions Pillow documents for unparseable files, so callers catching UnidentifiedImageError or ValueError do not catch it; and under python -O the assert is stripped, so the file is parsed as if valid.

This raises a ValueError instead, matching the existing "Invalid texture compression format" check in the same plugin. Added a regression test that patches the format count in a valid file, mirroring test_invalid_texture.

Used an AI assistant to find this; I reviewed and tested the change myself.

@radarhere radarhere added the 🤖-assisted AI-assisted label Jul 21, 2026
@radarhere

Copy link
Copy Markdown
Member

So are you saying you actually encountered a multi-format file in the wild?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖-assisted AI-assisted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants