Skip to content

Commit be8e55d

Browse files
committed
Added deprecation warning
1 parent a922126 commit be8e55d

File tree

7 files changed

+84
-1
lines changed

7 files changed

+84
-1
lines changed

Tests/test_image.py

+5
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,11 @@ def test_getxmp_padded(self) -> None:
989989
else:
990990
assert im.getxmp() == {"xmpmeta": None}
991991

992+
def test_get_child_images(self) -> None:
993+
im = Image.new("RGB", (1, 1))
994+
with pytest.warns(DeprecationWarning):
995+
assert im.get_child_images() == []
996+
992997
@pytest.mark.parametrize("size", ((1, 0), (0, 1), (0, 0)))
993998
def test_zero_tobytes(self, size: tuple[int, int]) -> None:
994999
im = Image.new("RGB", size)

docs/deprecations.rst

+10
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,16 @@ ExifTags.IFD.Makernote
183183
``ExifTags.IFD.Makernote`` has been deprecated. Instead, use
184184
``ExifTags.IFD.MakerNote``.
185185

186+
Image.Image.get_child_images()
187+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
188+
189+
.. deprecated:: 11.2.0
190+
191+
``Image.Image.get_child_images()`` has been deprecated. and will be removed in Pillow
192+
13 (2026-10-15). It will be moved to ``ImageFile.ImageFile.get_child_images()``. The
193+
method uses an image's file pointer, and so child images could only be retrieved from
194+
an :py:class:`PIL.ImageFile.ImageFile` instance.
195+
186196
Removed features
187197
----------------
188198

docs/releasenotes/11.2.0.rst

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
11.2.0
2+
------
3+
4+
Security
5+
========
6+
7+
TODO
8+
^^^^
9+
10+
TODO
11+
12+
:cve:`YYYY-XXXXX`: TODO
13+
^^^^^^^^^^^^^^^^^^^^^^^
14+
15+
TODO
16+
17+
Backwards Incompatible Changes
18+
==============================
19+
20+
TODO
21+
^^^^
22+
23+
Deprecations
24+
============
25+
26+
Image.Image.get_child_images()
27+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
28+
29+
.. deprecated:: 11.2.0
30+
31+
``Image.Image.get_child_images()`` has been deprecated. and will be removed in Pillow
32+
13 (2026-10-15). It will be moved to ``ImageFile.ImageFile.get_child_images()``. The
33+
method uses an image's file pointer, and so child images could only be retrieved from
34+
an :py:class:`PIL.ImageFile.ImageFile` instance.
35+
36+
API Changes
37+
===========
38+
39+
TODO
40+
^^^^
41+
42+
TODO
43+
44+
API Additions
45+
=============
46+
47+
TODO
48+
^^^^
49+
50+
TODO
51+
52+
Other Changes
53+
=============
54+
55+
TODO
56+
^^^^
57+
58+
TODO

docs/releasenotes/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ expected to be backported to earlier versions.
1414
.. toctree::
1515
:maxdepth: 2
1616

17+
11.2.0
1718
11.1.0
1819
11.0.0
1920
10.4.0

src/PIL/Image.py

+6
Original file line numberDiff line numberDiff line change
@@ -1553,6 +1553,12 @@ def _reload_exif(self) -> None:
15531553
self._exif._loaded = False
15541554
self.getexif()
15551555

1556+
def get_child_images(self) -> list[ImageFile.ImageFile]:
1557+
from . import ImageFile
1558+
1559+
deprecate("Image.Image.get_child_images", 13)
1560+
return ImageFile.ImageFile.get_child_images(self) # type: ignore[arg-type]
1561+
15561562
def getim(self) -> CapsuleType:
15571563
"""
15581564
Returns a capsule that points to the internal image memory.

src/PIL/ImageFile.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ def get_child_images(self) -> list[ImageFile]:
180180
ifds.append((ifd1, exif._info.next))
181181

182182
offset = None
183-
assert self.fp is not None
184183
for ifd, ifd_offset in ifds:
184+
assert self.fp is not None
185185
current_offset = self.fp.tell()
186186
if offset is None:
187187
offset = current_offset
@@ -210,6 +210,7 @@ def get_child_images(self) -> list[ImageFile]:
210210
child_images.append(im)
211211

212212
if offset is not None:
213+
assert self.fp is not None
213214
self.fp.seek(offset)
214215
return child_images
215216

src/PIL/_deprecate.py

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ def deprecate(
4747
raise RuntimeError(msg)
4848
elif when == 12:
4949
removed = "Pillow 12 (2025-10-15)"
50+
elif when == 13:
51+
removed = "Pillow 13 (2026-10-15)"
5052
else:
5153
msg = f"Unknown removal version: {when}. Update {__name__}?"
5254
raise ValueError(msg)

0 commit comments

Comments
 (0)