Remove attributes deprecated since 3.2.0

This commit is contained in:
Hugo van Kemenade 2020-07-09 13:19:19 +03:00 committed by Andrew Murray
parent f2c4be799c
commit 559510b378
3 changed files with 9 additions and 152 deletions

View File

@ -435,39 +435,6 @@ def test_extended_information():
assert p.xcolor_space == "RGB " assert p.xcolor_space == "RGB "
def test_deprecations():
skip_missing()
o = ImageCms.getOpenProfile(SRGB)
p = o.profile
def helper_deprecated(attr, expected):
result = pytest.warns(DeprecationWarning, getattr, p, attr)
assert result == expected
# p.color_space
helper_deprecated("color_space", "RGB")
# p.pcs
helper_deprecated("pcs", "XYZ")
# p.product_copyright
helper_deprecated(
"product_copyright", "Copyright International Color Consortium, 2009"
)
# p.product_desc
helper_deprecated("product_desc", "sRGB IEC61966-2-1 black scaled")
# p.product_description
helper_deprecated("product_description", "sRGB IEC61966-2-1 black scaled")
# p.product_manufacturer
helper_deprecated("product_manufacturer", "")
# p.product_model
helper_deprecated("product_model", "IEC 61966-2-1 Default RGB Colour Space - sRGB")
def test_profile_typesafety(): def test_profile_typesafety():
""" Profile init type safety """ Profile init type safety

View File

@ -49,16 +49,23 @@ PILLOW_VERSION constant
It was initially removed in Pillow 7.0.0, but brought back in 7.1.0 to give projects It was initially removed in Pillow 7.0.0, but brought back in 7.1.0 to give projects
more time to upgrade. more time to upgrade.
Removed features
----------------
Deprecated features are only removed in major releases after an appropriate
period of deprecation has passed.
ImageCms.CmsProfile attributes ImageCms.CmsProfile attributes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. deprecated:: 3.2.0 .. deprecated:: 3.2.0
.. versionremoved:: 8.0.0
Some attributes in ``ImageCms.CmsProfile`` are deprecated. From 6.0.0, they issue a Some attributes in ``ImageCms.CmsProfile`` have been removed. From 6.0.0, they issued a
``DeprecationWarning``: ``DeprecationWarning``:
======================== =============================== ======================== ===============================
Deprecated Use instead Removed Use instead
======================== =============================== ======================== ===============================
``color_space`` Padded ``xcolor_space`` ``color_space`` Padded ``xcolor_space``
``pcs`` Padded ``connection_space`` ``pcs`` Padded ``connection_space``
@ -69,12 +76,6 @@ Deprecated Use instead
``product_model`` Unicode ``model`` ``product_model`` Unicode ``model``
======================== =============================== ======================== ===============================
Removed features
----------------
Deprecated features are only removed in major releases after an appropriate
period of deprecation has passed.
Python 2.7 Python 2.7
~~~~~~~~~~ ~~~~~~~~~~

View File

@ -223,25 +223,6 @@ cms_transform_dealloc(CmsTransformObject* self)
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
/* internal functions */ /* internal functions */
static const char*
findICmode(cmsColorSpaceSignature cs)
{
switch (cs) {
case cmsSigXYZData: return "XYZ";
case cmsSigLabData: return "LAB";
case cmsSigLuvData: return "LUV";
case cmsSigYCbCrData: return "YCbCr";
case cmsSigYxyData: return "YXY";
case cmsSigRgbData: return "RGB";
case cmsSigGrayData: return "L";
case cmsSigHsvData: return "HSV";
case cmsSigHlsData: return "HLS";
case cmsSigCmykData: return "CMYK";
case cmsSigCmyData: return "CMY";
default: return ""; /* other TBA */
}
}
static cmsUInt32Number static cmsUInt32Number
findLCMStype(char* PILmode) findLCMStype(char* PILmode)
{ {
@ -956,92 +937,12 @@ static struct PyMethodDef cms_profile_methods[] = {
{NULL, NULL} /* sentinel */ {NULL, NULL} /* sentinel */
}; };
static PyObject*
_profile_getattr(CmsProfileObject* self, cmsInfoType field)
{
// UNDONE -- check that I'm getting the right fields on these.
// return PyUnicode_DecodeFSDefault(cmsTakeProductName(self->profile));
//wchar_t buf[256]; -- UNDONE need wchar_t for unicode version.
char buf[256];
cmsUInt32Number written;
written = cmsGetProfileInfoASCII(self->profile,
field,
"en",
"us",
buf,
256);
if (written) {
return PyUnicode_FromString(buf);
}
// UNDONE suppressing error here by sending back blank string.
return PyUnicode_FromString("");
}
static PyObject*
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
return _profile_getattr(self, cmsInfoDescription);
}
/* use these four for the individual fields.
*/
static PyObject*
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);
}
static PyObject*
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);
}
static PyObject*
cms_profile_getattr_product_manufacturer(CmsProfileObject* self, void* closure)
{
PyErr_WarnEx(PyExc_DeprecationWarning,
"product_manufacturer is deprecated. Use Unicode manufacturer instead.", 1);
return _profile_getattr(self, cmsInfoManufacturer);
}
static PyObject*
cms_profile_getattr_product_copyright(CmsProfileObject* self, void* closure)
{
PyErr_WarnEx(PyExc_DeprecationWarning,
"product_copyright is deprecated. Use Unicode copyright instead.", 1);
return _profile_getattr(self, cmsInfoCopyright);
}
static PyObject* static PyObject*
cms_profile_getattr_rendering_intent(CmsProfileObject* self, void* closure) cms_profile_getattr_rendering_intent(CmsProfileObject* self, void* closure)
{ {
return PyLong_FromLong(cmsGetHeaderRenderingIntent(self->profile)); return PyLong_FromLong(cmsGetHeaderRenderingIntent(self->profile));
} }
static PyObject*
cms_profile_getattr_pcs(CmsProfileObject* self, void* closure)
{
PyErr_WarnEx(PyExc_DeprecationWarning,
"pcs 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)));
}
/* New-style unicode interfaces. */ /* New-style unicode interfaces. */
static PyObject* static PyObject*
cms_profile_getattr_copyright(CmsProfileObject* self, void* closure) cms_profile_getattr_copyright(CmsProfileObject* self, void* closure)
@ -1149,14 +1050,12 @@ cms_profile_getattr_device_class(CmsProfileObject* self, void* closure)
return _profile_read_int_as_string(cmsGetDeviceClass(self->profile)); return _profile_read_int_as_string(cmsGetDeviceClass(self->profile));
} }
/* Duplicate of pcs, but uninterpreted. */
static PyObject* static PyObject*
cms_profile_getattr_connection_space(CmsProfileObject* self, void* closure) cms_profile_getattr_connection_space(CmsProfileObject* self, void* closure)
{ {
return _profile_read_int_as_string(cmsGetPCS(self->profile)); return _profile_read_int_as_string(cmsGetPCS(self->profile));
} }
/* Duplicate of color_space, but uninterpreted. */
static PyObject* static PyObject*
cms_profile_getattr_xcolor_space(CmsProfileObject* self, void* closure) cms_profile_getattr_xcolor_space(CmsProfileObject* self, void* closure)
{ {
@ -1458,15 +1357,6 @@ cms_profile_getattr_icc_viewing_condition (CmsProfileObject* self, void* closure
static struct PyGetSetDef cms_profile_getsetters[] = { static struct PyGetSetDef cms_profile_getsetters[] = {
/* Compatibility interfaces. */
{ "product_desc", (getter) cms_profile_getattr_product_desc },
{ "product_description", (getter) cms_profile_getattr_product_description },
{ "product_manufacturer", (getter) cms_profile_getattr_product_manufacturer },
{ "product_model", (getter) cms_profile_getattr_product_model },
{ "product_copyright", (getter) cms_profile_getattr_product_copyright },
{ "pcs", (getter) cms_profile_getattr_pcs },
{ "color_space", (getter) cms_profile_getattr_color_space },
/* New style interfaces. */ /* New style interfaces. */
{ "rendering_intent", (getter) cms_profile_getattr_rendering_intent }, { "rendering_intent", (getter) cms_profile_getattr_rendering_intent },
{ "creation_date", (getter) cms_profile_getattr_creation_date }, { "creation_date", (getter) cms_profile_getattr_creation_date },
@ -1485,7 +1375,6 @@ static struct PyGetSetDef cms_profile_getsetters[] = {
{ "header_model", (getter) cms_profile_getattr_header_model }, { "header_model", (getter) cms_profile_getattr_header_model },
{ "device_class", (getter) cms_profile_getattr_device_class }, { "device_class", (getter) cms_profile_getattr_device_class },
{ "connection_space", (getter) cms_profile_getattr_connection_space }, { "connection_space", (getter) cms_profile_getattr_connection_space },
/* Similar to color_space, but with full 4-letter signature (including trailing whitespace). */
{ "xcolor_space", (getter) cms_profile_getattr_xcolor_space }, { "xcolor_space", (getter) cms_profile_getattr_xcolor_space },
{ "profile_id", (getter) cms_profile_getattr_profile_id }, { "profile_id", (getter) cms_profile_getattr_profile_id },
{ "is_matrix_shaper", (getter) cms_profile_getattr_is_matrix_shaper }, { "is_matrix_shaper", (getter) cms_profile_getattr_is_matrix_shaper },