Moved line after early return

Improve compiler advice

Update src/PIL/features.py
This commit is contained in:
Andrew Murray 2024-08-13 06:46:46 +10:00 committed by Aleksandr Karpinskii
parent 6180abc75c
commit 924df9e60b
2 changed files with 4 additions and 5 deletions

View File

@ -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:

View File

@ -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);