Skip to content

Conversation

@radarhere
Copy link
Member

For

Pillow/src/_webp.c

Lines 956 to 974 in 6b71090

static int
setup_module(PyObject *m) {
PyObject *d = PyModule_GetDict(m);
addMuxFlagToModule(m);
addAnimFlagToModule(m);
addTransparencyFlagToModule(m);
PyDict_SetItemString(
d, "webpdecoder_version", PyUnicode_FromString(WebPDecoderVersion_str()));
#ifdef HAVE_WEBPANIM
/* Ready object types */
if (PyType_Ready(&WebPAnimDecoder_Type) < 0 ||
PyType_Ready(&WebPAnimEncoder_Type) < 0) {
return -1;
}
#endif
return 0;
}

this PR rearranges the code to run the PyType_Ready conditional first, so it the code fails earlier, and d is not created for potentially no reason (m isn't used if setup_module returns -1).

@hugovk hugovk merged commit 436ebdb into python-pillow:main Mar 12, 2023
@radarhere radarhere deleted the setup_module branch March 12, 2023 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants