From e7eac4f80b5ef243573029c9c5fb89f28eecde7d Mon Sep 17 00:00:00 2001 From: Hugo Date: Mon, 28 Jan 2019 09:01:02 +0200 Subject: [PATCH] Add warnings to deprecated CMS profile attributes --- Tests/test_imagecms.py | 12 ++++++++++-- src/_imagingcms.c | 4 ++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Tests/test_imagecms.py b/Tests/test_imagecms.py index b4d53a2df..ee3a2b92e 100644 --- a/Tests/test_imagecms.py +++ b/Tests/test_imagecms.py @@ -309,7 +309,11 @@ class TestImageCms(PillowTestCase): 2: (False, False, True), 3: (False, False, True) }) - self.assertEqual(p.color_space, 'RGB') + + # p.color_space + result = self.assert_warning(DeprecationWarning, getattr, p, "color_space") + self.assertEqual(result, 'RGB') + self.assertIsNone(p.colorant_table) self.assertIsNone(p.colorant_table_out) self.assertIsNone(p.colorimetric_intent) @@ -361,7 +365,11 @@ class TestImageCms(PillowTestCase): (5000.722328847392,)) self.assertEqual(p.model, 'IEC 61966-2-1 Default RGB Colour Space - sRGB') - self.assertEqual(p.pcs, 'XYZ') + + # p.pcs + result = self.assert_warning(DeprecationWarning, getattr, p, "pcs") + self.assertEqual(result, 'XYZ') + self.assertIsNone(p.perceptual_rendering_intent_gamut) self.assertEqual(p.product_copyright, 'Copyright International Color Consortium, 2009') diff --git a/src/_imagingcms.c b/src/_imagingcms.c index 80cef2668..51b987f8d 100644 --- a/src/_imagingcms.c +++ b/src/_imagingcms.c @@ -1005,12 +1005,16 @@ cms_profile_getattr_rendering_intent(CmsProfileObject* self, void* closure) static PyObject* cms_profile_getattr_pcs(CmsProfileObject* self, void* closure) { + PyErr_WarnEx(PyExc_DeprecationWarning, + "cms is deprecated. Use padded connection_space instead.", 1); return PyUnicode_DecodeFSDefault(findICmode(cmsGetPCS(self->profile))); } static PyObject* cms_profile_getattr_color_space(CmsProfileObject* self, void* closure) { + PyErr_WarnEx(PyExc_DeprecationWarning, + "color_space is deprecated. Use padded xcolor_space instead.", 1); return PyUnicode_DecodeFSDefault(findICmode(cmsGetColorSpace(self->profile))); }