diff --git a/Tests/test_imagefile.py b/Tests/test_imagefile.py index a9444c26d..d4dfb1b6d 100644 --- a/Tests/test_imagefile.py +++ b/Tests/test_imagefile.py @@ -151,11 +151,6 @@ class TestImageFile: # Despite multiple tiles, assert only one tile caused a read of maxblock size assert reads.count(im.decodermaxblock) == 1 - def test_raise_oserror(self) -> None: - with pytest.warns(DeprecationWarning, match="raise_oserror"): - with pytest.raises(OSError): - ImageFile.raise_oserror(1) - def test_raise_typeerror(self) -> None: with pytest.raises(TypeError): parser = ImageFile.Parser() diff --git a/docs/deprecations.rst b/docs/deprecations.rst index 5ecd7de42..4a208f212 100644 --- a/docs/deprecations.rst +++ b/docs/deprecations.rst @@ -12,16 +12,6 @@ Deprecated features Below are features which are considered deprecated. Where appropriate, a :py:exc:`DeprecationWarning` is issued. -ImageFile.raise_oserror -~~~~~~~~~~~~~~~~~~~~~~~ - -.. deprecated:: 10.2.0 - -``ImageFile.raise_oserror()`` has been deprecated and will be removed in Pillow -12.0.0 (2025-10-15). The function is undocumented and is only useful for translating -error codes returned by a codec's ``decode()`` method, which ImageFile already does -automatically. - IptcImageFile helper functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -206,6 +196,16 @@ Removed features Deprecated features are only removed in major releases after an appropriate period of deprecation has passed. +ImageFile.raise_oserror +~~~~~~~~~~~~~~~~~~~~~~~ + +.. deprecated:: 10.2.0 +.. versionremoved:: 12.0.0 + +``ImageFile.raise_oserror()`` has been removed. The function was undocumented and was +only useful for translating error codes returned by a codec's ``decode()`` method, +which ImageFile already did automatically. + BGR;15, BGR 16 and BGR;24 ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/PIL/ImageFile.py b/src/PIL/ImageFile.py index bf556a2c6..27b27127e 100644 --- a/src/PIL/ImageFile.py +++ b/src/PIL/ImageFile.py @@ -37,7 +37,6 @@ import struct from typing import IO, Any, NamedTuple, cast from . import ExifTags, Image -from ._deprecate import deprecate from ._util import DeferredError, is_path TYPE_CHECKING = False @@ -83,16 +82,6 @@ def _get_oserror(error: int, *, encoder: bool) -> OSError: return OSError(msg) -def raise_oserror(error: int) -> OSError: - deprecate( - "raise_oserror", - 12, - action="It is only useful for translating error codes returned by a codec's " - "decode() method, which ImageFile already does automatically.", - ) - raise _get_oserror(error, encoder=False) - - def _tilesort(t: _Tile) -> int: # sort on offset return t[2]