Skip to content

Conversation

@radarhere
Copy link
Member

I was just looking at

def test_unbound_local() -> None:
# prepatch, a malformed jp2 file could cause an UnboundLocalError exception.
with pytest.raises(OSError):
with Image.open("Tests/images/unbound_variable.jp2"):
pass

which triggers a SyntaxError
if size is None or mode is None:
msg = "Malformed JP2 header"
raise SyntaxError(msg)

and wondering why that didn't lead to an UnidentifiedImageError.

The answer was that it did, but UnidentifiedImageError inherits from OSError, so the test passed without a problem.

class UnidentifiedImageError(OSError):

This PR just updated the test to check for UnidentifiedImageError, to be clearer.

@hugovk hugovk merged commit 02e8bf9 into python-pillow:main Jun 25, 2024
@radarhere radarhere deleted the jpeg2k_error branch June 25, 2024 20:07
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