From 0a29d6392afeaf6c7e8354dbfa67a1f9268028df Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Tue, 1 Jul 2025 20:29:45 +1000 Subject: [PATCH] Removed IptcImageFile helper functions --- Tests/test_file_iptc.py | 37 +--------------------- docs/deprecations.rst | 64 +++++++++++++++++++------------------- src/PIL/IptcImagePlugin.py | 24 -------------- 3 files changed, 33 insertions(+), 92 deletions(-) diff --git a/Tests/test_file_iptc.py b/Tests/test_file_iptc.py index 5dca3da21..3c4c892c8 100644 --- a/Tests/test_file_iptc.py +++ b/Tests/test_file_iptc.py @@ -1,9 +1,6 @@ from __future__ import annotations -import sys -from io import BytesIO, StringIO - -import pytest +from io import BytesIO from PIL import Image, IptcImagePlugin, TiffImagePlugin, TiffTags @@ -101,35 +98,3 @@ def test_getiptcinfo_tiff_none() -> None: # Assert assert iptc is None - - -def test_i() -> None: - # Arrange - c = b"a" - - # Act - with pytest.warns(DeprecationWarning, match="IptcImagePlugin.i"): - ret = IptcImagePlugin.i(c) - - # Assert - assert ret == 97 - - -def test_dump(monkeypatch: pytest.MonkeyPatch) -> None: - # Arrange - c = b"abc" - # Temporarily redirect stdout - mystdout = StringIO() - monkeypatch.setattr(sys, "stdout", mystdout) - - # Act - with pytest.warns(DeprecationWarning, match="IptcImagePlugin.dump"): - IptcImagePlugin.dump(c) - - # Assert - assert mystdout.getvalue() == "61 62 63 \n" - - -def test_pad_deprecation() -> None: - with pytest.warns(DeprecationWarning, match="IptcImagePlugin.PAD"): - assert IptcImagePlugin.PAD == b"\0\0\0\0" diff --git a/docs/deprecations.rst b/docs/deprecations.rst index 5973038e3..06767c20b 100644 --- a/docs/deprecations.rst +++ b/docs/deprecations.rst @@ -12,17 +12,6 @@ Deprecated features Below are features which are considered deprecated. Where appropriate, a :py:exc:`DeprecationWarning` is issued. -IptcImageFile helper functions -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. deprecated:: 10.2.0 - -The functions ``IptcImageFile.dump`` and ``IptcImageFile.i``, and the constant -``IptcImageFile.PAD`` have been deprecated and will be removed in Pillow -12.0.0 (2025-10-15). These are undocumented helper functions intended -for internal use, so there is no replacement. They can each be replaced -by a single line of code using builtin functions in Python. - ImageCms constants and versions() function ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -160,14 +149,6 @@ Removed features Deprecated features are only removed in major releases after an appropriate period of deprecation has passed. -ImageDraw.getdraw hints parameter -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. deprecated:: 10.4.0 -.. versionremoved:: 12.0.0 - -The ``hints`` parameter in :py:meth:`~PIL.ImageDraw.getdraw()` has been removed. - ImageFile.raise_oserror ~~~~~~~~~~~~~~~~~~~~~~~ @@ -178,22 +159,16 @@ ImageFile.raise_oserror 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 -^^^^^^^^^^^^^^^^^^^^^^^^^ +IptcImageFile helper functions +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. deprecated:: 10.4.0 +.. deprecated:: 10.2.0 .. versionremoved:: 12.0.0 -The experimental BGR;15, BGR;16 and BGR;24 modes have been removed. - -Support for LibTIFF earlier than 4 -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -.. deprecated:: 10.4.0 -.. versionremoved:: 12.0.0 - -Support for LibTIFF earlier than version 4 has been removed. -Upgrade to a newer version of LibTIFF instead. +The functions ``IptcImageFile.dump`` and ``IptcImageFile.i``, and the constant +``IptcImageFile.PAD`` have been removed. These were undocumented helper functions +intended for internal use, so there is no replacement. They can each be replaced by a +single line of code using builtin functions in Python. Image isImageType() ^^^^^^^^^^^^^^^^^^^ @@ -233,6 +208,31 @@ removed. They were used for obtaining raw pointers to ``ImagingCore`` internals. interact with C code, you can use ``Image.Image.getim()``, which returns a ``Capsule`` object. +BGR;15, BGR 16 and BGR;24 +^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. deprecated:: 10.4.0 +.. versionremoved:: 12.0.0 + +The experimental BGR;15, BGR;16 and BGR;24 modes have been removed. + +Support for LibTIFF earlier than 4 +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. deprecated:: 10.4.0 +.. versionremoved:: 12.0.0 + +Support for LibTIFF earlier than version 4 has been removed. +Upgrade to a newer version of LibTIFF instead. + +ImageDraw.getdraw hints parameter +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. deprecated:: 10.4.0 +.. versionremoved:: 12.0.0 + +The ``hints`` parameter in :py:meth:`~PIL.ImageDraw.getdraw()` has been removed. + TiffImagePlugin IFD_LEGACY_API ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/src/PIL/IptcImagePlugin.py b/src/PIL/IptcImagePlugin.py index fc024d668..b1fbb1bf1 100644 --- a/src/PIL/IptcImagePlugin.py +++ b/src/PIL/IptcImagePlugin.py @@ -16,26 +16,16 @@ # from __future__ import annotations -from collections.abc import Sequence from io import BytesIO from typing import cast from . import Image, ImageFile from ._binary import i16be as i16 from ._binary import i32be as i32 -from ._deprecate import deprecate COMPRESSION = {1: "raw", 5: "jpeg"} -def __getattr__(name: str) -> bytes: - if name == "PAD": - deprecate("IptcImagePlugin.PAD", 12) - return b"\0\0\0\0" - msg = f"module '{__name__}' has no attribute '{name}'" - raise AttributeError(msg) - - # # Helpers @@ -48,20 +38,6 @@ def _i8(c: int | bytes) -> int: return c if isinstance(c, int) else c[0] -def i(c: bytes) -> int: - """.. deprecated:: 10.2.0""" - deprecate("IptcImagePlugin.i", 12) - return _i(c) - - -def dump(c: Sequence[int | bytes]) -> None: - """.. deprecated:: 10.2.0""" - deprecate("IptcImagePlugin.dump", 12) - for i in c: - print(f"{_i8(i):02x}", end=" ") - print() - - ## # Image plugin for IPTC/NAA datastreams. To read IPTC/NAA fields # from TIFF and JPEG files, use the getiptcinfo function.