summaryrefslogtreecommitdiffstats
path: root/Programs/_freeze_importlib.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-05-22 21:58:50 (GMT)
committerGitHub <noreply@github.com>2019-05-22 21:58:50 (GMT)
commit022be02dcfdfd9011415804bb4553a33fa7ec8f3 (patch)
tree6c4f3b4afed8475e6504786cb176044eade9ef02 /Programs/_freeze_importlib.c
parente4d300e07c33a9a77549c62d8687d8fe130c53d5 (diff)
downloadcpython-022be02dcfdfd9011415804bb4553a33fa7ec8f3.zip
cpython-022be02dcfdfd9011415804bb4553a33fa7ec8f3.tar.gz
cpython-022be02dcfdfd9011415804bb4553a33fa7ec8f3.tar.bz2
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.
Diffstat (limited to 'Programs/_freeze_importlib.c')
-rw-r--r--Programs/_freeze_importlib.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/Programs/_freeze_importlib.c b/Programs/_freeze_importlib.c
index 1a719e2..8cf44d3 100644
--- a/Programs/_freeze_importlib.c
+++ b/Programs/_freeze_importlib.c
@@ -76,18 +76,30 @@ main(int argc, char *argv[])
}
text[text_size] = '\0';
+ _PyInitError err;
_PyCoreConfig config;
- _PyCoreConfig_InitIsolatedConfig(&config);
+
+ err = _PyCoreConfig_InitIsolatedConfig(&config);
+ if (_PyInitError_Failed(err)) {
+ _PyCoreConfig_Clear(&config);
+ _Py_ExitInitError(err);
+ }
config.site_import = 0;
- config.program_name = L"./_freeze_importlib";
+
+ err = _PyCoreConfig_SetString(&config, &config.program_name,
+ L"./_freeze_importlib");
+ if (_PyInitError_Failed(err)) {
+ _PyCoreConfig_Clear(&config);
+ _Py_ExitInitError(err);
+ }
+
/* Don't install importlib, since it could execute outdated bytecode. */
config._install_importlib = 0;
config._init_main = 0;
- _PyInitError err = _Py_InitializeFromConfig(&config);
- /* No need to call _PyCoreConfig_Clear() since we didn't allocate any
- memory: program_name is a constant string. */
+ err = _Py_InitializeFromConfig(&config);
+ _PyCoreConfig_Clear(&config);
if (_PyInitError_Failed(err)) {
_Py_ExitInitError(err);
}