mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-12 18:26:17 +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,
|
||||||
assert_image_similar_tofile,
|
assert_image_similar_tofile,
|
||||||
hopper,
|
hopper,
|
||||||
|
is_pypy,
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -501,11 +502,7 @@ def test_non_ascii_path(tmp_path: Path) -> None:
|
||||||
|
|
||||||
|
|
||||||
def test_profile_typesafety() -> None:
|
def test_profile_typesafety() -> None:
|
||||||
"""Profile init type safety
|
# does not segfault
|
||||||
|
|
||||||
prepatch, these would segfault, postpatch they should emit a typeerror
|
|
||||||
"""
|
|
||||||
|
|
||||||
with pytest.raises(TypeError, match="Invalid type for Profile"):
|
with pytest.raises(TypeError, match="Invalid type for Profile"):
|
||||||
ImageCms.ImageCmsProfile(0).tobytes()
|
ImageCms.ImageCmsProfile(0).tobytes()
|
||||||
with pytest.raises(TypeError, match="Invalid type for Profile"):
|
with pytest.raises(TypeError, match="Invalid type for Profile"):
|
||||||
|
@ -517,6 +514,13 @@ def test_profile_typesafety() -> None:
|
||||||
with pytest.raises(TypeError):
|
with pytest.raises(TypeError):
|
||||||
ImageCms.core.profile_tobytes(1)
|
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(
|
def assert_aux_channel_preserved(
|
||||||
mode: str, transform_in_place: bool, preserved_channel: str
|
mode: str, transform_in_place: bool, preserved_channel: str
|
||||||
|
|
|
@ -1511,8 +1511,6 @@ setup_module(PyObject *m) {
|
||||||
PyObject *v;
|
PyObject *v;
|
||||||
int vn;
|
int vn;
|
||||||
|
|
||||||
CmsProfile_Type.tp_new = PyType_GenericNew;
|
|
||||||
|
|
||||||
/* Ready object types */
|
/* Ready object types */
|
||||||
PyType_Ready(&CmsProfile_Type);
|
PyType_Ready(&CmsProfile_Type);
|
||||||
PyType_Ready(&CmsTransform_Type);
|
PyType_Ready(&CmsTransform_Type);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user