mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 09:26:16 +03:00
Add warnings to deprecated CMS profile attributes
This commit is contained in:
parent
e1381d2102
commit
3476474359
|
@ -378,9 +378,15 @@ class TestImageCms(PillowTestCase):
|
||||||
)
|
)
|
||||||
self.assertEqual(result, "Copyright International Color Consortium, 2009")
|
self.assertEqual(result, "Copyright International Color Consortium, 2009")
|
||||||
|
|
||||||
self.assertEqual(p.product_desc, 'sRGB IEC61966-2-1 black scaled')
|
# p.product_desc
|
||||||
self.assertEqual(p.product_description,
|
result = self.assert_warning(DeprecationWarning, getattr, p, "product_desc")
|
||||||
'sRGB IEC61966-2-1 black scaled')
|
self.assertEqual(result, "sRGB IEC61966-2-1 black scaled")
|
||||||
|
|
||||||
|
# p.product_description
|
||||||
|
result = self.assert_warning(
|
||||||
|
DeprecationWarning, getattr, p, "product_description"
|
||||||
|
)
|
||||||
|
self.assertEqual(result, "sRGB IEC61966-2-1 black scaled")
|
||||||
|
|
||||||
# p.product_manufacturer
|
# p.product_manufacturer
|
||||||
result = self.assert_warning(
|
result = self.assert_warning(
|
||||||
|
|
|
@ -690,7 +690,7 @@ def getProfileName(profile):
|
||||||
manufacturer = profile.profile.manufacturer
|
manufacturer = profile.profile.manufacturer
|
||||||
|
|
||||||
if not (model or manufacturer):
|
if not (model or manufacturer):
|
||||||
return profile.profile.product_description + "\n"
|
return (profile.profile.profile_description or "") + "\n"
|
||||||
if not manufacturer or len(model) > 30:
|
if not manufacturer or len(model) > 30:
|
||||||
return model + "\n"
|
return model + "\n"
|
||||||
return "%s - %s\n" % (model, manufacturer)
|
return "%s - %s\n" % (model, manufacturer)
|
||||||
|
@ -727,7 +727,7 @@ def getProfileInfo(profile):
|
||||||
# Python, not C. the white point bits weren't working well,
|
# Python, not C. the white point bits weren't working well,
|
||||||
# so skipping.
|
# so skipping.
|
||||||
# info was description \r\n\r\n copyright \r\n\r\n K007 tag \r\n\r\n whitepoint
|
# info was description \r\n\r\n copyright \r\n\r\n K007 tag \r\n\r\n whitepoint
|
||||||
description = profile.profile.product_description
|
description = profile.profile.profile_description
|
||||||
cpright = profile.profile.copyright
|
cpright = profile.profile.copyright
|
||||||
arr = []
|
arr = []
|
||||||
for elt in (description, cpright):
|
for elt in (description, cpright):
|
||||||
|
@ -848,7 +848,7 @@ def getProfileDescription(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_description + "\n"
|
return (profile.profile.profile_description or "") + "\n"
|
||||||
except (AttributeError, IOError, TypeError, ValueError) as v:
|
except (AttributeError, IOError, TypeError, ValueError) as v:
|
||||||
raise PyCMSError(v)
|
raise PyCMSError(v)
|
||||||
|
|
||||||
|
|
|
@ -966,6 +966,8 @@ _profile_getattr(CmsProfileObject* self, cmsInfoType field)
|
||||||
static PyObject*
|
static PyObject*
|
||||||
cms_profile_getattr_product_desc(CmsProfileObject* self, void* closure)
|
cms_profile_getattr_product_desc(CmsProfileObject* self, void* closure)
|
||||||
{
|
{
|
||||||
|
PyErr_WarnEx(PyExc_DeprecationWarning,
|
||||||
|
"product_desc is deprecated. Use Unicode profile_description instead.", 1);
|
||||||
// description was Description != 'Copyright' || or "%s - %s" (manufacturer, model) in 1.x
|
// description was Description != 'Copyright' || or "%s - %s" (manufacturer, model) in 1.x
|
||||||
return _profile_getattr(self, cmsInfoDescription);
|
return _profile_getattr(self, cmsInfoDescription);
|
||||||
}
|
}
|
||||||
|
@ -975,6 +977,8 @@ cms_profile_getattr_product_desc(CmsProfileObject* self, void* closure)
|
||||||
static PyObject*
|
static PyObject*
|
||||||
cms_profile_getattr_product_description(CmsProfileObject* self, void* closure)
|
cms_profile_getattr_product_description(CmsProfileObject* self, void* closure)
|
||||||
{
|
{
|
||||||
|
PyErr_WarnEx(PyExc_DeprecationWarning,
|
||||||
|
"product_description is deprecated. Use Unicode profile_description instead.", 1);
|
||||||
return _profile_getattr(self, cmsInfoDescription);
|
return _profile_getattr(self, cmsInfoDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user