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: try:
imported_module = __import__(module, fromlist=["PIL"]) imported_module = __import__(module, fromlist=["PIL"])
if isinstance(flag, str): if isinstance(flag, bool):
return getattr(imported_module, flag)
else:
_deprecate.deprecate(f'check_feature("{feature}")', 12) _deprecate.deprecate(f'check_feature("{feature}")', 12)
return flag return flag
return getattr(imported_module, flag)
except ModuleNotFoundError: except ModuleNotFoundError:
return None return None
except ImportError as ex: except ImportError as ex:

View File

@ -14,7 +14,7 @@
* versions, before enabling animation support. * versions, before enabling animation support.
*/ */
#if WEBP_MUX_ABI_VERSION < 0x0106 || WEBP_DEMUX_ABI_VERSION < 0x0107 #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 #endif
void void
@ -784,13 +784,13 @@ static PyMethodDef webpMethods[] = {
static int static int
setup_module(PyObject *m) { setup_module(PyObject *m) {
PyObject *d = PyModule_GetDict(m);
/* Ready object types */ /* Ready object types */
if (PyType_Ready(&WebPAnimDecoder_Type) < 0 || if (PyType_Ready(&WebPAnimDecoder_Type) < 0 ||
PyType_Ready(&WebPAnimEncoder_Type) < 0) { PyType_Ready(&WebPAnimEncoder_Type) < 0) {
return -1; return -1;
} }
PyObject *d = PyModule_GetDict(m);
PyObject *v = PyUnicode_FromString(WebPDecoderVersion_str()); PyObject *v = PyUnicode_FromString(WebPDecoderVersion_str());
PyDict_SetItemString(d, "webpdecoder_version", v ? v : Py_None); PyDict_SetItemString(d, "webpdecoder_version", v ? v : Py_None);
Py_XDECREF(v); Py_XDECREF(v);