From 022be02dcfdfd9011415804bb4553a33fa7ec8f3 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 22 May 2019 23:58:50 +0200 Subject: bpo-36763: Add _PyPreConfig._config_init (GH-13481) * _PyPreConfig_GetGlobalConfig() and _PyCoreConfig_GetGlobalConfig() now do nothing if the configuration was not initialized with _PyPreConfig_InitCompatConfig() and _PyCoreConfig_InitCompatConfig() * Remove utf8_mode=-2 special case: use utf8_mode=-1 instead. * Fix _PyPreConfig_InitPythonConfig(): * isolated = 0 instead of -1 * use_environment = 1 instead of -1 * Rename _PyConfig_INIT to _PyConfig_INIT_COMPAT * Rename _PyPreConfig_Init() to _PyPreConfig_InitCompatConfig() * Rename _PyCoreConfig_Init() to _PyCoreConfig_InitCompatConfig() * PyInterpreterState_New() now uses _PyCoreConfig_InitPythonConfig() as default configuration, but it's very quickly overriden anyway. * _freeze_importlib.c uses _PyCoreConfig_SetString() to set program_name. * Cleanup preconfig_init_utf8_mode(): cmdline is always non-NULL. --- Python/frozenmain.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'Python/frozenmain.c') diff --git a/Python/frozenmain.c b/Python/frozenmain.c index a51fb58001..c3af080401 100644 --- a/Python/frozenmain.c +++ b/Python/frozenmain.c @@ -40,7 +40,11 @@ Py_FrozenMain(int argc, char **argv) } _PyCoreConfig config; - _PyCoreConfig_InitPythonConfig(&config); + err = _PyCoreConfig_InitPythonConfig(&config); + if (_PyInitError_Failed(err)) { + _PyCoreConfig_Clear(&config); + _Py_ExitInitError(err); + } config.pathconfig_warnings = 0; /* Suppress errors from getpath.c */ if ((p = Py_GETENV("PYTHONINSPECT")) && *p != '\0') @@ -82,8 +86,7 @@ Py_FrozenMain(int argc, char **argv) Py_SetProgramName(argv_copy[0]); err = _Py_InitializeFromConfig(&config); - /* No need to call _PyCoreConfig_Clear() since we didn't allocate any - memory: program_name is a constant string. */ + _PyCoreConfig_Clear(&config); if (_PyInitError_Failed(err)) { _Py_ExitInitError(err); } -- cgit v1.2.1