Skip to content

Commit 924df9e

Browse files
radarherehomm
authored andcommitted
Moved line after early return
Improve compiler advice Update src/PIL/features.py
1 parent 6180abc commit 924df9e

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/PIL/features.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,10 @@ def check_feature(feature: str) -> bool | None:
148148

149149
try:
150150
imported_module = __import__(module, fromlist=["PIL"])
151-
if isinstance(flag, str):
152-
return getattr(imported_module, flag)
153-
else:
151+
if isinstance(flag, bool):
154152
_deprecate.deprecate(f'check_feature("{feature}")', 12)
155153
return flag
154+
return getattr(imported_module, flag)
156155
except ModuleNotFoundError:
157156
return None
158157
except ImportError as ex:

src/_webp.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* versions, before enabling animation support.
1515
*/
1616
#if WEBP_MUX_ABI_VERSION < 0x0106 || WEBP_DEMUX_ABI_VERSION < 0x0107
17-
#error libwebp 0.5.0 and above is required. Upgrade libwebp or build with --disable-webp flag
17+
#error libwebp 0.5.0 and above is required. Upgrade libwebp or build Pillow with --disable-webp flag
1818
#endif
1919

2020
void
@@ -784,13 +784,13 @@ static PyMethodDef webpMethods[] = {
784784

785785
static int
786786
setup_module(PyObject *m) {
787-
PyObject *d = PyModule_GetDict(m);
788787
/* Ready object types */
789788
if (PyType_Ready(&WebPAnimDecoder_Type) < 0 ||
790789
PyType_Ready(&WebPAnimEncoder_Type) < 0) {
791790
return -1;
792791
}
793792

793+
PyObject *d = PyModule_GetDict(m);
794794
PyObject *v = PyUnicode_FromString(WebPDecoderVersion_str());
795795
PyDict_SetItemString(d, "webpdecoder_version", v ? v : Py_None);
796796
Py_XDECREF(v);

0 commit comments

Comments
 (0)