diff --git a/Tests/test_imagecms.py b/Tests/test_imagecms.py index 6be29a70f..c04d08806 100644 --- a/Tests/test_imagecms.py +++ b/Tests/test_imagecms.py @@ -506,6 +506,12 @@ def test_profile_typesafety() -> None: with pytest.raises(TypeError, match="Invalid type for Profile"): ImageCms.ImageCmsProfile(1).tobytes() + # also check core function + with pytest.raises(TypeError): + ImageCms.core.profile_tobytes(0) + with pytest.raises(TypeError): + ImageCms.core.profile_tobytes(1) + def assert_aux_channel_preserved( mode: str, transform_in_place: bool, preserved_channel: str diff --git a/src/_imagingcms.c b/src/_imagingcms.c index c7728770a..7c7763653 100644 --- a/src/_imagingcms.c +++ b/src/_imagingcms.c @@ -143,7 +143,7 @@ cms_profile_tobytes(PyObject *self, PyObject *args) { cmsHPROFILE *profile; PyObject *ret; - if (!PyArg_ParseTuple(args, "O", &CmsProfile)) { + if (!PyArg_ParseTuple(args, "O!", &CmsProfile_Type, &CmsProfile)) { return NULL; }