Skip to content

Commit

Permalink
do not allow ImageCms.core.CmsProfile to be instantiated directly
Browse files Browse the repository at this point in the history
  • Loading branch information
nulano committed Jan 20, 2024
1 parent 2a45ab6 commit 1bfa30a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 6 additions & 5 deletions Tests/test_imagecms.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,11 +494,6 @@ def test_non_ascii_path(tmp_path):


def test_profile_typesafety():
"""Profile init type safety
prepatch, these would segfault, postpatch they should emit a typeerror
"""

with pytest.raises(TypeError, match="Invalid type for Profile"):
ImageCms.ImageCmsProfile(0).tobytes()
with pytest.raises(TypeError, match="Invalid type for Profile"):
Expand All @@ -510,6 +505,12 @@ def test_profile_typesafety():
with pytest.raises(TypeError):
ImageCms.core.profile_tobytes(1)

# core profile should not be directly instantiable
with pytest.raises(TypeError):
ImageCms.core.CmsProfile()
with pytest.raises(TypeError):
ImageCms.core.CmsProfile(0)


def assert_aux_channel_preserved(mode, transform_in_place, preserved_channel):
def create_test_image():
Expand Down
2 changes: 0 additions & 2 deletions src/_imagingcms.c
Original file line number Diff line number Diff line change
Expand Up @@ -1511,8 +1511,6 @@ setup_module(PyObject *m) {
PyObject *v;
int vn;

CmsProfile_Type.tp_new = PyType_GenericNew;

/* Ready object types */
PyType_Ready(&CmsProfile_Type);
PyType_Ready(&CmsTransform_Type);
Expand Down

0 comments on commit 1bfa30a

Please sign in to comment.