Skip to content

Commit bd63c4f

Browse files
authored
Deprecate Image._show (#9186)
2 parents 9e73e6e + 8777073 commit bd63c4f

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

Tests/test_image.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
ImageDraw,
2020
ImageFile,
2121
ImagePalette,
22+
ImageShow,
2223
UnidentifiedImageError,
2324
features,
2425
)
@@ -1047,6 +1048,13 @@ def test_get_child_images(self) -> None:
10471048
with pytest.warns(DeprecationWarning, match="Image.Image.get_child_images"):
10481049
assert im.get_child_images() == []
10491050

1051+
def test_show(self, monkeypatch: pytest.MonkeyPatch) -> None:
1052+
monkeypatch.setattr(ImageShow, "_viewers", [])
1053+
1054+
im = Image.new("RGB", (1, 1))
1055+
with pytest.warns(DeprecationWarning, match="Image._show"):
1056+
Image._show(im)
1057+
10501058
@pytest.mark.parametrize("size", ((1, 0), (0, 1), (0, 0)))
10511059
def test_zero_tobytes(self, size: tuple[int, int]) -> None:
10521060
im = Image.new("RGB", size)

docs/deprecations.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ ImageCms.ImageCmsProfile.product_name and .product_info
6161
``.product_info`` attributes have been deprecated, and will be removed in
6262
Pillow 13 (2026-10-15). They have been set to ``None`` since Pillow 2.3.0.
6363

64+
Image._show
65+
~~~~~~~~~~~
66+
67+
.. deprecated:: 12.0.0
68+
69+
``Image._show`` has been deprecated, and will be removed in Pillow 13 (2026-10-15).
70+
Use :py:meth:`~PIL.ImageShow.show` instead.
71+
6472
Removed features
6573
----------------
6674

docs/releasenotes/12.0.0.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ vulnerability introduced in FreeType 2.6 (:cve:`2020-15999`).
116116
Deprecations
117117
============
118118

119+
Image._show
120+
^^^^^^^^^^^
121+
122+
``Image._show`` has been deprecated, and will be removed in Pillow 13 (2026-10-15).
123+
Use :py:meth:`~PIL.ImageShow.show` instead.
124+
119125
ImageCms.ImageCmsProfile.product_name and .product_info
120126
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
121127

src/PIL/Image.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2632,7 +2632,9 @@ def show(self, title: str | None = None) -> None:
26322632
:param title: Optional title to use for the image window, where possible.
26332633
"""
26342634

2635-
_show(self, title=title)
2635+
from . import ImageShow
2636+
2637+
ImageShow.show(self, title)
26362638

26372639
def split(self) -> tuple[Image, ...]:
26382640
"""
@@ -3797,6 +3799,7 @@ def register_encoder(name: str, encoder: type[ImageFile.PyEncoder]) -> None:
37973799
def _show(image: Image, **options: Any) -> None:
37983800
from . import ImageShow
37993801

3802+
deprecate("Image._show", 13, "ImageShow.show")
38003803
ImageShow.show(image, **options)
38013804

38023805

0 commit comments

Comments
 (0)