mirror of
https://github.com/python/cpython.git
synced 2025-08-30 13:38:43 +00:00
bpo-36763: Add _Py_InitializeMain() (GH-13362)
* Add a private _Py_InitializeMain() function. * Add again _PyCoreConfig._init_main. * _Py_InitializeFromConfig() now uses _init_main to decide if _Py_InitializeMainInterpreter() should be called. * _PyCoreConfig: rename _frozen to pathconfig_warnings, its value is now the opposite of Py_FrozenFlag. * Add an unit test for _init_main=0 and _Py_InitializeMain().
This commit is contained in:
parent
ae239f6b06
commit
9ef5dcaa0b
10 changed files with 130 additions and 40 deletions
|
@ -970,6 +970,21 @@ _Py_InitializeMainInterpreter(_PyRuntimeState *runtime,
|
|||
return _Py_INIT_OK();
|
||||
}
|
||||
|
||||
|
||||
_PyInitError
|
||||
_Py_InitializeMain(void)
|
||||
{
|
||||
_PyInitError err = _PyRuntime_Initialize();
|
||||
if (_Py_INIT_FAILED(err)) {
|
||||
return err;
|
||||
}
|
||||
_PyRuntimeState *runtime = &_PyRuntime;
|
||||
PyInterpreterState *interp = _PyRuntimeState_GetThreadState(runtime)->interp;
|
||||
|
||||
return _Py_InitializeMainInterpreter(runtime, interp);
|
||||
}
|
||||
|
||||
|
||||
#undef _INIT_DEBUG_PRINT
|
||||
|
||||
static _PyInitError
|
||||
|
@ -990,7 +1005,7 @@ init_python(const _PyCoreConfig *config, const _PyArgv *args)
|
|||
}
|
||||
config = &interp->core_config;
|
||||
|
||||
if (!config->_frozen) {
|
||||
if (config->_init_main) {
|
||||
err = _Py_InitializeMainInterpreter(runtime, interp);
|
||||
if (_Py_INIT_FAILED(err)) {
|
||||
return err;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue