Removed ImageFile raise_oserror()

This commit is contained in:
Andrew Murray 2025-07-01 20:07:31 +10:00
parent 5d4a05465d
commit 1800e580d2
3 changed files with 10 additions and 26 deletions

View File

@ -151,11 +151,6 @@ class TestImageFile:
# Despite multiple tiles, assert only one tile caused a read of maxblock size # Despite multiple tiles, assert only one tile caused a read of maxblock size
assert reads.count(im.decodermaxblock) == 1 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: def test_raise_typeerror(self) -> None:
with pytest.raises(TypeError): with pytest.raises(TypeError):
parser = ImageFile.Parser() parser = ImageFile.Parser()

View File

@ -12,16 +12,6 @@ Deprecated features
Below are features which are considered deprecated. Where appropriate, Below are features which are considered deprecated. Where appropriate,
a :py:exc:`DeprecationWarning` is issued. 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 IptcImageFile helper functions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -206,6 +196,16 @@ Removed features
Deprecated features are only removed in major releases after an appropriate Deprecated features are only removed in major releases after an appropriate
period of deprecation has passed. 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 BGR;15, BGR 16 and BGR;24
^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -37,7 +37,6 @@ import struct
from typing import IO, Any, NamedTuple, cast from typing import IO, Any, NamedTuple, cast
from . import ExifTags, Image from . import ExifTags, Image
from ._deprecate import deprecate
from ._util import DeferredError, is_path from ._util import DeferredError, is_path
TYPE_CHECKING = False TYPE_CHECKING = False
@ -83,16 +82,6 @@ def _get_oserror(error: int, *, encoder: bool) -> OSError:
return OSError(msg) 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: def _tilesort(t: _Tile) -> int:
# sort on offset # sort on offset
return t[2] return t[2]