Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Tests/test_imagecms.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,3 +690,17 @@ def test_cmyk_lab() -> None:
im = Image.new("CMYK", (1, 1))
converted_im = im.convert("LAB")
assert converted_im.getpixel((0, 0)) == (255, 128, 128)


def test_deprecation() -> None:
profile = ImageCmsProfile(ImageCms.createProfile("sRGB"))
with pytest.warns(
DeprecationWarning, match="ImageCms.ImageCmsProfile.product_name"
):
profile.product_name
with pytest.warns(
DeprecationWarning, match="ImageCms.ImageCmsProfile.product_info"
):
profile.product_info
with pytest.raises(AttributeError):
profile.this_attribute_does_not_exist
9 changes: 9 additions & 0 deletions docs/deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ another mode before saving::
im = Image.new("I", (1, 1))
im.convert("I;16").save("out.png")

ImageCms.ImageCmsProfile.product_name and .product_info
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. deprecated:: 12.0.0

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

Removed features
----------------

Expand Down
8 changes: 5 additions & 3 deletions docs/releasenotes/12.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,12 @@ vulnerability introduced in FreeType 2.6 (:cve:`2020-15999`).
Deprecations
============

TODO
^^^^
ImageCms.ImageCmsProfile.product_name and .product_info
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

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

API changes
===========
Expand Down
14 changes: 10 additions & 4 deletions src/PIL/ImageCms.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
import sys
from enum import IntEnum, IntFlag
from functools import reduce
from typing import Literal, SupportsFloat, SupportsInt, Union
from typing import Any, Literal, SupportsFloat, SupportsInt, Union

from . import Image
from ._deprecate import deprecate
from ._typing import SupportsRead

try:
Expand Down Expand Up @@ -233,9 +234,7 @@ def __init__(self, profile: str | SupportsRead[bytes] | core.CmsProfile) -> None
low-level profile object

"""
self.filename = None
self.product_name = None # profile.product_name
self.product_info = None # profile.product_info
self.filename: str | None = None

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

def __getattr__(self, name: str) -> Any:
if name in ("product_name", "product_info"):
deprecate(f"ImageCms.ImageCmsProfile.{name}", 13)
return None
msg = f"'{self.__class__.__name__}' object has no attribute '{name}'"
raise AttributeError(msg)

def tobytes(self) -> bytes:
"""
Returns the profile in a format suitable for embedding in
Expand Down
Loading