From 924df9e60b39c6ced91553895497fa43db2d232d Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Tue, 13 Aug 2024 06:46:46 +1000 Subject: [PATCH] Moved line after early return Improve compiler advice Update src/PIL/features.py --- src/PIL/features.py | 5 ++--- src/_webp.c | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/PIL/features.py b/src/PIL/features.py index f594a2cdc4a..a5487042ead 100644 --- a/src/PIL/features.py +++ b/src/PIL/features.py @@ -148,11 +148,10 @@ def check_feature(feature: str) -> bool | None: try: imported_module = __import__(module, fromlist=["PIL"]) - if isinstance(flag, str): - return getattr(imported_module, flag) - else: + if isinstance(flag, bool): _deprecate.deprecate(f'check_feature("{feature}")', 12) return flag + return getattr(imported_module, flag) except ModuleNotFoundError: return None except ImportError as ex: diff --git a/src/_webp.c b/src/_webp.c index 8302925b0fc..306a290bdb9 100644 --- a/src/_webp.c +++ b/src/_webp.c @@ -14,7 +14,7 @@ * versions, before enabling animation support. */ #if WEBP_MUX_ABI_VERSION < 0x0106 || WEBP_DEMUX_ABI_VERSION < 0x0107 -#error libwebp 0.5.0 and above is required. Upgrade libwebp or build with --disable-webp flag +#error libwebp 0.5.0 and above is required. Upgrade libwebp or build Pillow with --disable-webp flag #endif void @@ -784,13 +784,13 @@ static PyMethodDef webpMethods[] = { static int setup_module(PyObject *m) { - PyObject *d = PyModule_GetDict(m); /* Ready object types */ if (PyType_Ready(&WebPAnimDecoder_Type) < 0 || PyType_Ready(&WebPAnimEncoder_Type) < 0) { return -1; } + PyObject *d = PyModule_GetDict(m); PyObject *v = PyUnicode_FromString(WebPDecoderVersion_str()); PyDict_SetItemString(d, "webpdecoder_version", v ? v : Py_None); Py_XDECREF(v);