When PEP 587 "Python Initialization Configuration" (PyConfig C API) has been implemented, the code to initialize Python was scattered in many places, and it was a tedious task to move all options to the new PyConfig structure.
The PyConfig structure has a wart that I always hated: Py_InitializeFromConfig() can fail with an exit code. It requires the caller to handle this special case: "Python wants to exit".
I propose moving the processing of command line options which want to exit Python: process these options in Py_RunMain() instead. So Py_InitializeFromConfig() can no longer exit with an "exit status": PyStatus_IsExit(status) is always false.
Py_RunMain() return value is an exit code, so it's more natural to process the command line options there.
PEP 741 "Python Configuration C API" just inherited its "exit status" from PyConfig in PyInitConfig. If we fix Py_InitializeFromConfig(), Py_InitializeFromInitConfig() will be fixed as well.
Linked PRs
When PEP 587 "Python Initialization Configuration" (
PyConfigC API) has been implemented, the code to initialize Python was scattered in many places, and it was a tedious task to move all options to the newPyConfigstructure.The
PyConfigstructure has a wart that I always hated:Py_InitializeFromConfig()can fail with an exit code. It requires the caller to handle this special case: "Python wants to exit".I propose moving the processing of command line options which want to exit Python: process these options in
Py_RunMain()instead. SoPy_InitializeFromConfig()can no longer exit with an "exit status":PyStatus_IsExit(status)is always false.Py_RunMain()return value is an exit code, so it's more natural to process the command line options there.PEP 741 "Python Configuration C API" just inherited its "exit status" from
PyConfiginPyInitConfig. If we fixPy_InitializeFromConfig(),Py_InitializeFromInitConfig()will be fixed as well.Linked PRs