From 24c0569f8d4e2ec105c721116a2e7c47af35c032 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Mon, 12 Aug 2024 18:52:38 +1000 Subject: [PATCH 1/2] Do not return string from check_feature() --- src/PIL/features.py | 2 +- src/_imaging.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/PIL/features.py b/src/PIL/features.py index 9f4735aee06..ac7dbcb7fac 100644 --- a/src/PIL/features.py +++ b/src/PIL/features.py @@ -128,7 +128,7 @@ def get_supported_codecs() -> list[str]: "libjpeg_turbo": ("PIL._imaging", "HAVE_LIBJPEGTURBO", "libjpeg_turbo_version"), "libimagequant": ("PIL._imaging", "HAVE_LIBIMAGEQUANT", "imagequant_version"), "xcb": ("PIL._imaging", "HAVE_XCB", None), - "acceleration": ("PIL._imaging", "acceleration", "acceleration"), + "acceleration": ("PIL._imaging", "HAVE_ACCELERATION", "acceleration"), } diff --git a/src/_imaging.c b/src/_imaging.c index 84c1d55c39d..b639cd8a84e 100644 --- a/src/_imaging.c +++ b/src/_imaging.c @@ -4407,6 +4407,7 @@ setup_module(PyObject *m) { Py_INCREF(have_xcb); PyModule_AddObject(m, "HAVE_XCB", have_xcb); + PyObject *have_acceleration = Py_True; #ifdef __AVX2__ PyModule_AddStringConstant(m, "acceleration", "avx2"); #elif defined(__SSE4__) @@ -4418,7 +4419,11 @@ setup_module(PyObject *m) { #else Py_INCREF(Py_False); PyModule_AddObject(m, "acceleration", Py_False); + + have_acceleration = Py_False; #endif + Py_INCREF(have_acceleration); + PyModule_AddObject(m, "HAVE_ACCELERATION", have_acceleration); PyObject *pillow_version = PyUnicode_FromString(version); PyDict_SetItemString( From 55a97f9ddfebfa27df3541ddb988c07ba5194574 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Mon, 12 Aug 2024 18:27:16 +1000 Subject: [PATCH 2/2] Do not return bool from version_feature() --- src/_imaging.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/_imaging.c b/src/_imaging.c index b639cd8a84e..184f5fb98a6 100644 --- a/src/_imaging.c +++ b/src/_imaging.c @@ -4417,8 +4417,8 @@ setup_module(PyObject *m) { #elif defined(__NEON__) PyModule_AddStringConstant(m, "acceleration", "neon"); #else - Py_INCREF(Py_False); - PyModule_AddObject(m, "acceleration", Py_False); + Py_INCREF(Py_None); + PyModule_AddObject(m, "acceleration", Py_None); have_acceleration = Py_False; #endif