Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use more specific error #8168

Merged
merged 1 commit into from
Jun 25, 2024
Merged

Use more specific error #8168

merged 1 commit into from
Jun 25, 2024

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
55 checks passed
@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.

None yet

2 participants