Skip to content

Commit ec6d5ef

Browse files
lukegbradarhere
andauthored
Deprecate ImageCmsProfile product_name and product_info (#8995)
Co-authored-by: Andrew Murray <[email protected]>
1 parent 640f55a commit ec6d5ef

File tree

4 files changed

+38
-7
lines changed

4 files changed

+38
-7
lines changed

Tests/test_imagecms.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,3 +690,17 @@ def test_cmyk_lab() -> None:
690690
im = Image.new("CMYK", (1, 1))
691691
converted_im = im.convert("LAB")
692692
assert converted_im.getpixel((0, 0)) == (255, 128, 128)
693+
694+
695+
def test_deprecation() -> None:
696+
profile = ImageCmsProfile(ImageCms.createProfile("sRGB"))
697+
with pytest.warns(
698+
DeprecationWarning, match="ImageCms.ImageCmsProfile.product_name"
699+
):
700+
profile.product_name
701+
with pytest.warns(
702+
DeprecationWarning, match="ImageCms.ImageCmsProfile.product_info"
703+
):
704+
profile.product_info
705+
with pytest.raises(AttributeError):
706+
profile.this_attribute_does_not_exist

docs/deprecations.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ another mode before saving::
5252
im = Image.new("I", (1, 1))
5353
im.convert("I;16").save("out.png")
5454

55+
ImageCms.ImageCmsProfile.product_name and .product_info
56+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
57+
58+
.. deprecated:: 12.0.0
59+
60+
``ImageCms.ImageCmsProfile.product_name`` and the corresponding
61+
``.product_info`` attributes have been deprecated, and will be removed in
62+
Pillow 13 (2026-10-15). They have been set to ``None`` since Pillow 2.3.0.
63+
5564
Removed features
5665
----------------
5766

docs/releasenotes/12.0.0.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,12 @@ vulnerability introduced in FreeType 2.6 (:cve:`2020-15999`).
110110
Deprecations
111111
============
112112

113-
TODO
114-
^^^^
113+
ImageCms.ImageCmsProfile.product_name and .product_info
114+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
115115

116-
TODO
116+
``ImageCms.ImageCmsProfile.product_name`` and the corresponding
117+
``.product_info`` attributes have been deprecated, and will be removed in
118+
Pillow 13 (2026-10-15). They have been set to ``None`` since Pillow 2.3.0.
117119

118120
API changes
119121
===========

src/PIL/ImageCms.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@
2323
import sys
2424
from enum import IntEnum, IntFlag
2525
from functools import reduce
26-
from typing import Literal, SupportsFloat, SupportsInt, Union
26+
from typing import Any, Literal, SupportsFloat, SupportsInt, Union
2727

2828
from . import Image
29+
from ._deprecate import deprecate
2930
from ._typing import SupportsRead
3031

3132
try:
@@ -233,9 +234,7 @@ def __init__(self, profile: str | SupportsRead[bytes] | core.CmsProfile) -> None
233234
low-level profile object
234235
235236
"""
236-
self.filename = None
237-
self.product_name = None # profile.product_name
238-
self.product_info = None # profile.product_info
237+
self.filename: str | None = None
239238

240239
if isinstance(profile, str):
241240
if sys.platform == "win32":
@@ -256,6 +255,13 @@ def __init__(self, profile: str | SupportsRead[bytes] | core.CmsProfile) -> None
256255
msg = "Invalid type for Profile" # type: ignore[unreachable]
257256
raise TypeError(msg)
258257

258+
def __getattr__(self, name: str) -> Any:
259+
if name in ("product_name", "product_info"):
260+
deprecate(f"ImageCms.ImageCmsProfile.{name}", 13)
261+
return None
262+
msg = f"'{self.__class__.__name__}' object has no attribute '{name}'"
263+
raise AttributeError(msg)
264+
259265
def tobytes(self) -> bytes:
260266
"""
261267
Returns the profile in a format suitable for embedding in

0 commit comments

Comments
 (0)