Add warnings to deprecated CMS profile attributes

This commit is contained in:
Hugo 2019-01-28 10:37:56 +02:00
parent e7eac4f80b
commit 7d157bd825
4 changed files with 14 additions and 9 deletions

View File

@ -377,8 +377,11 @@ class TestImageCms(PillowTestCase):
self.assertEqual(p.product_description, self.assertEqual(p.product_description,
'sRGB IEC61966-2-1 black scaled') 'sRGB IEC61966-2-1 black scaled')
self.assertEqual(p.product_manufacturer, '') self.assertEqual(p.product_manufacturer, '')
self.assertEqual(
p.product_model, 'IEC 61966-2-1 Default RGB Colour Space - sRGB') # p.product_model
result = self.assert_warning(DeprecationWarning, getattr, p, "product_model")
self.assertEqual(result, "IEC 61966-2-1 Default RGB Colour Space - sRGB")
self.assertEqual( self.assertEqual(
p.profile_description, 'sRGB IEC61966-2-1 black scaled') p.profile_description, 'sRGB IEC61966-2-1 black scaled')
self.assertEqual( self.assertEqual(

View File

@ -132,21 +132,21 @@ can be easily displayed in a chromaticity diagram, for example).
.. py:attribute:: manufacturer .. py:attribute:: manufacturer
The (english) display string for the device manufacturer (see The (English) display string for the device manufacturer (see
9.2.22 of ICC.1:2010). 9.2.22 of ICC.1:2010).
:type: :py:class:`unicode` or ``None`` :type: :py:class:`unicode` or ``None``
.. py:attribute:: model .. py:attribute:: model
The (english) display string for the device model of the device The (English) display string for the device model of the device
for which this profile is created (see 9.2.23 of ICC.1:2010). for which this profile is created (see 9.2.23 of ICC.1:2010).
:type: :py:class:`unicode` or ``None`` :type: :py:class:`unicode` or ``None``
.. py:attribute:: profile_description .. py:attribute:: profile_description
The (english) display string for the profile description (see The (English) display string for the profile description (see
9.2.41 of ICC.1:2010). 9.2.41 of ICC.1:2010).
:type: :py:class:`unicode` or ``None`` :type: :py:class:`unicode` or ``None``
@ -269,14 +269,14 @@ can be easily displayed in a chromaticity diagram, for example).
.. py:attribute:: viewing_condition .. py:attribute:: viewing_condition
The (english) display string for the viewing conditions (see The (English) display string for the viewing conditions (see
9.2.48 of ICC.1:2010). 9.2.48 of ICC.1:2010).
:type: :py:class:`unicode` or ``None`` :type: :py:class:`unicode` or ``None``
.. py:attribute:: screening_description .. py:attribute:: screening_description
The (english) display string for the screening conditions. The (English) display string for the screening conditions.
This tag was available in ICC 3.2, but it is removed from This tag was available in ICC 3.2, but it is removed from
version 4. version 4.

View File

@ -686,7 +686,7 @@ def getProfileName(profile):
# // name was "%s - %s" (model, manufacturer) || Description , # // name was "%s - %s" (model, manufacturer) || Description ,
# // but if the Model and Manufacturer were the same or the model # // but if the Model and Manufacturer were the same or the model
# // was long, Just the model, in 1.x # // was long, Just the model, in 1.x
model = profile.profile.product_model model = profile.profile.model
manufacturer = profile.profile.product_manufacturer manufacturer = profile.profile.product_manufacturer
if not (model or manufacturer): if not (model or manufacturer):
@ -819,7 +819,7 @@ def getProfileModel(profile):
# add an extra newline to preserve pyCMS compatibility # add an extra newline to preserve pyCMS compatibility
if not isinstance(profile, ImageCmsProfile): if not isinstance(profile, ImageCmsProfile):
profile = ImageCmsProfile(profile) profile = ImageCmsProfile(profile)
return profile.profile.product_model + "\n" return profile.profile.model + "\n"
except (AttributeError, IOError, TypeError, ValueError) as v: except (AttributeError, IOError, TypeError, ValueError) as v:
raise PyCMSError(v) raise PyCMSError(v)

View File

@ -981,6 +981,8 @@ cms_profile_getattr_product_description(CmsProfileObject* self, void* closure)
static PyObject* static PyObject*
cms_profile_getattr_product_model(CmsProfileObject* self, void* closure) cms_profile_getattr_product_model(CmsProfileObject* self, void* closure)
{ {
PyErr_WarnEx(PyExc_DeprecationWarning,
"product_model is deprecated. Use Unicode model instead.", 1);
return _profile_getattr(self, cmsInfoModel); return _profile_getattr(self, cmsInfoModel);
} }