Skip to content

Commit 0a29d63

Browse files
committed
Removed IptcImageFile helper functions
1 parent 9c9449a commit 0a29d63

File tree

3 files changed

+33
-92
lines changed

3 files changed

+33
-92
lines changed

Tests/test_file_iptc.py

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
from __future__ import annotations
22

3-
import sys
4-
from io import BytesIO, StringIO
5-
6-
import pytest
3+
from io import BytesIO
74

85
from PIL import Image, IptcImagePlugin, TiffImagePlugin, TiffTags
96

@@ -101,35 +98,3 @@ def test_getiptcinfo_tiff_none() -> None:
10198

10299
# Assert
103100
assert iptc is None
104-
105-
106-
def test_i() -> None:
107-
# Arrange
108-
c = b"a"
109-
110-
# Act
111-
with pytest.warns(DeprecationWarning, match="IptcImagePlugin.i"):
112-
ret = IptcImagePlugin.i(c)
113-
114-
# Assert
115-
assert ret == 97
116-
117-
118-
def test_dump(monkeypatch: pytest.MonkeyPatch) -> None:
119-
# Arrange
120-
c = b"abc"
121-
# Temporarily redirect stdout
122-
mystdout = StringIO()
123-
monkeypatch.setattr(sys, "stdout", mystdout)
124-
125-
# Act
126-
with pytest.warns(DeprecationWarning, match="IptcImagePlugin.dump"):
127-
IptcImagePlugin.dump(c)
128-
129-
# Assert
130-
assert mystdout.getvalue() == "61 62 63 \n"
131-
132-
133-
def test_pad_deprecation() -> None:
134-
with pytest.warns(DeprecationWarning, match="IptcImagePlugin.PAD"):
135-
assert IptcImagePlugin.PAD == b"\0\0\0\0"

docs/deprecations.rst

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,6 @@ Deprecated features
1212
Below are features which are considered deprecated. Where appropriate,
1313
a :py:exc:`DeprecationWarning` is issued.
1414

15-
IptcImageFile helper functions
16-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17-
18-
.. deprecated:: 10.2.0
19-
20-
The functions ``IptcImageFile.dump`` and ``IptcImageFile.i``, and the constant
21-
``IptcImageFile.PAD`` have been deprecated and will be removed in Pillow
22-
12.0.0 (2025-10-15). These are undocumented helper functions intended
23-
for internal use, so there is no replacement. They can each be replaced
24-
by a single line of code using builtin functions in Python.
25-
2615
ImageCms constants and versions() function
2716
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2817

@@ -160,14 +149,6 @@ Removed features
160149
Deprecated features are only removed in major releases after an appropriate
161150
period of deprecation has passed.
162151

163-
ImageDraw.getdraw hints parameter
164-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
165-
166-
.. deprecated:: 10.4.0
167-
.. versionremoved:: 12.0.0
168-
169-
The ``hints`` parameter in :py:meth:`~PIL.ImageDraw.getdraw()` has been removed.
170-
171152
ImageFile.raise_oserror
172153
~~~~~~~~~~~~~~~~~~~~~~~
173154

@@ -178,22 +159,16 @@ ImageFile.raise_oserror
178159
only useful for translating error codes returned by a codec's ``decode()`` method,
179160
which ImageFile already did automatically.
180161

181-
BGR;15, BGR 16 and BGR;24
182-
^^^^^^^^^^^^^^^^^^^^^^^^^
183-
184-
.. deprecated:: 10.4.0
185-
.. versionremoved:: 12.0.0
186-
187-
The experimental BGR;15, BGR;16 and BGR;24 modes have been removed.
188-
189-
Support for LibTIFF earlier than 4
190-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
162+
IptcImageFile helper functions
163+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
191164

192-
.. deprecated:: 10.4.0
165+
.. deprecated:: 10.2.0
193166
.. versionremoved:: 12.0.0
194167

195-
Support for LibTIFF earlier than version 4 has been removed.
196-
Upgrade to a newer version of LibTIFF instead.
168+
The functions ``IptcImageFile.dump`` and ``IptcImageFile.i``, and the constant
169+
``IptcImageFile.PAD`` have been removed. These were undocumented helper functions
170+
intended for internal use, so there is no replacement. They can each be replaced by a
171+
single line of code using builtin functions in Python.
197172

198173
Image isImageType()
199174
^^^^^^^^^^^^^^^^^^^
@@ -233,6 +208,31 @@ removed. They were used for obtaining raw pointers to ``ImagingCore`` internals.
233208
interact with C code, you can use ``Image.Image.getim()``, which returns a ``Capsule``
234209
object.
235210

211+
BGR;15, BGR 16 and BGR;24
212+
^^^^^^^^^^^^^^^^^^^^^^^^^
213+
214+
.. deprecated:: 10.4.0
215+
.. versionremoved:: 12.0.0
216+
217+
The experimental BGR;15, BGR;16 and BGR;24 modes have been removed.
218+
219+
Support for LibTIFF earlier than 4
220+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
221+
222+
.. deprecated:: 10.4.0
223+
.. versionremoved:: 12.0.0
224+
225+
Support for LibTIFF earlier than version 4 has been removed.
226+
Upgrade to a newer version of LibTIFF instead.
227+
228+
ImageDraw.getdraw hints parameter
229+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
230+
231+
.. deprecated:: 10.4.0
232+
.. versionremoved:: 12.0.0
233+
234+
The ``hints`` parameter in :py:meth:`~PIL.ImageDraw.getdraw()` has been removed.
235+
236236
TiffImagePlugin IFD_LEGACY_API
237237
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
238238

src/PIL/IptcImagePlugin.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,16 @@
1616
#
1717
from __future__ import annotations
1818

19-
from collections.abc import Sequence
2019
from io import BytesIO
2120
from typing import cast
2221

2322
from . import Image, ImageFile
2423
from ._binary import i16be as i16
2524
from ._binary import i32be as i32
26-
from ._deprecate import deprecate
2725

2826
COMPRESSION = {1: "raw", 5: "jpeg"}
2927

3028

31-
def __getattr__(name: str) -> bytes:
32-
if name == "PAD":
33-
deprecate("IptcImagePlugin.PAD", 12)
34-
return b"\0\0\0\0"
35-
msg = f"module '{__name__}' has no attribute '{name}'"
36-
raise AttributeError(msg)
37-
38-
3929
#
4030
# Helpers
4131

@@ -48,20 +38,6 @@ def _i8(c: int | bytes) -> int:
4838
return c if isinstance(c, int) else c[0]
4939

5040

51-
def i(c: bytes) -> int:
52-
""".. deprecated:: 10.2.0"""
53-
deprecate("IptcImagePlugin.i", 12)
54-
return _i(c)
55-
56-
57-
def dump(c: Sequence[int | bytes]) -> None:
58-
""".. deprecated:: 10.2.0"""
59-
deprecate("IptcImagePlugin.dump", 12)
60-
for i in c:
61-
print(f"{_i8(i):02x}", end=" ")
62-
print()
63-
64-
6541
##
6642
# Image plugin for IPTC/NAA datastreams. To read IPTC/NAA fields
6743
# from TIFF and JPEG files, use the <b>getiptcinfo</b> function.

0 commit comments

Comments
 (0)