mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
do not allow ImageCms.core.CmsProfile to be instantiated directly
This commit is contained in:
parent
afd6e1fa29
commit
047a0d2a64
|
@ -19,6 +19,7 @@ from .helper import (
|
|||
assert_image_similar,
|
||||
assert_image_similar_tofile,
|
||||
hopper,
|
||||
is_pypy,
|
||||
)
|
||||
|
||||
try:
|
||||
|
@ -501,11 +502,7 @@ def test_non_ascii_path(tmp_path: Path) -> None:
|
|||
|
||||
|
||||
def test_profile_typesafety() -> None:
|
||||
"""Profile init type safety
|
||||
|
||||
prepatch, these would segfault, postpatch they should emit a typeerror
|
||||
"""
|
||||
|
||||
# does not segfault
|
||||
with pytest.raises(TypeError, match="Invalid type for Profile"):
|
||||
ImageCms.ImageCmsProfile(0).tobytes()
|
||||
with pytest.raises(TypeError, match="Invalid type for Profile"):
|
||||
|
@ -517,6 +514,13 @@ def test_profile_typesafety() -> None:
|
|||
with pytest.raises(TypeError):
|
||||
ImageCms.core.profile_tobytes(1)
|
||||
|
||||
if not is_pypy():
|
||||
# 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: str, transform_in_place: bool, preserved_channel: str
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user