-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Closed
Labels
3.14bugs and security fixesbugs and security fixestopic-C-APItype-featureA feature request or enhancementA feature request or enhancement
Description
Feature or enhancement
I think that it would simplify the code if make PyInitConfig_Free(NULL)
a no-op. Currently it requires the argument to be non-NULL. This would simplify the code:
PyInitConfig *config = NULL;
// some code
if (error_occurred) {
goto Error;
}
config = PyInitConfig_Create();
if (config == NULL) {
goto Error;
}
// some other code
if (error_occurred) {
goto Error;
}
// more code
Error:
// release resources
if (config == NULL) {
PyInitConfig_Free(config);
}
// release resources
Most Python resources are represented as Python objects, so Py_XDECREF(NULL)
works for them. PyMem_Free(NULL)
and PyRawMem_Free(NULL)
work for raw memory blocks. PyInitConfig_Free()
is one of few (or only one) API that cannot be used in such idiom.
Linked PRs
erlend-aasland, tomasr8, efimov-mikhail and ZeroIntensity
Metadata
Metadata
Assignees
Labels
3.14bugs and security fixesbugs and security fixestopic-C-APItype-featureA feature request or enhancementA feature request or enhancement