From 466da649f5b8bbd21233a62bdef1a1024c0a0c83 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Mon, 20 Jan 2020 20:04:17 +1100 Subject: [PATCH 1/2] get_display_profile is only supported on Windows --- src/PIL/ImageCms.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/PIL/ImageCms.py b/src/PIL/ImageCms.py index d05b3102c..9f60fc73b 100644 --- a/src/PIL/ImageCms.py +++ b/src/PIL/ImageCms.py @@ -254,20 +254,15 @@ def get_display_profile(handle=None): :returns: None if the profile is not known. """ - if sys.platform == "win32": - from PIL import ImageWin + if sys.platform != "win32": + return - if isinstance(handle, ImageWin.HDC): - profile = core.get_display_profile_win32(handle, 1) - else: - profile = core.get_display_profile_win32(handle or 0) + from PIL import ImageWin + + if isinstance(handle, ImageWin.HDC): + profile = core.get_display_profile_win32(handle, 1) else: - try: - get = _imagingcms.get_display_profile - except AttributeError: - return None - else: - profile = get() + profile = core.get_display_profile_win32(handle or 0) return ImageCmsProfile(profile) From b0b30970180e09fcaa8d52a500db2cb185f6b1b5 Mon Sep 17 00:00:00 2001 From: Andrew Murray <3112309+radarhere@users.noreply.github.com> Date: Sun, 16 Feb 2020 06:55:58 +1100 Subject: [PATCH 2/2] Explicity return None Co-Authored-By: Hugo van Kemenade --- src/PIL/ImageCms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PIL/ImageCms.py b/src/PIL/ImageCms.py index 9f60fc73b..c26fd14f2 100644 --- a/src/PIL/ImageCms.py +++ b/src/PIL/ImageCms.py @@ -255,7 +255,7 @@ def get_display_profile(handle=None): """ if sys.platform != "win32": - return + return None from PIL import ImageWin