bpo-34008: Allow to call Py_Main() after Py_Initialize() (GH-8043)

Py_Main() can again be called after Py_Initialize(), as in Python
3.6. The new configuration is ignored, except of
_PyMainInterpreterConfig.argv which is used to update sys.argv.
This commit is contained in:
Victor Stinner 2018-07-20 17:34:23 +02:00 committed by GitHub
parent 2c5c0a367c
commit fb47bca9ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 52 additions and 6 deletions

View file

@ -2696,9 +2696,13 @@ pymain_main(_PyMain *pymain)
pymain_init_stdio(pymain);
pymain->err = _Py_InitializeCore(&pymain->config);
if (_Py_INIT_FAILED(pymain->err)) {
_Py_FatalInitError(pymain->err);
/* bpo-34008: For backward compatibility reasons, calling Py_Main() after
Py_Initialize() ignores the new configuration. */
if (!_PyRuntime.initialized) {
pymain->err = _Py_InitializeCore(&pymain->config);
if (_Py_INIT_FAILED(pymain->err)) {
_Py_FatalInitError(pymain->err);
}
}
if (pymain_init_python_main(pymain) < 0) {