Skip to content

Commit

Permalink
OSError caused by decode error should use string argument to be in li…
Browse files Browse the repository at this point in the history
…ne with rest of module
  • Loading branch information
HarmvandenBrand committed Jan 3, 2025
1 parent 22d50fd commit 21cc5c1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Tests/test_file_libtiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,7 @@ def test_realloc_overflow(self, monkeypatch: pytest.MonkeyPatch) -> None:
im.load()

# Assert that the error code is IMAGING_CODEC_MEMORY
assert str(e.value) == "-9"
assert str(e.value) == "decoder error: -9"

@pytest.mark.parametrize("compression", ("tiff_adobe_deflate", "jpeg"))
def test_save_multistrip(self, compression: str, tmp_path: Path) -> None:
Expand Down
3 changes: 2 additions & 1 deletion src/PIL/TiffImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1406,7 +1406,8 @@ def _load_libtiff(self) -> Image.core.PixelAccess | None:
self.fp = None # might be shared

if err < 0:
raise OSError(err)
msg = f"decoder error: {err}"
raise OSError(msg)

return Image.Image.load(self)

Expand Down

0 comments on commit 21cc5c1

Please sign in to comment.