summaryrefslogtreecommitdiffstats
path: root/Programs/_freeze_importlib.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-08-05 10:31:59 (GMT)
committerGitHub <noreply@github.com>2018-08-05 10:31:59 (GMT)
commit0c90d6f75931da4fec84d06c2efe9dd94bb96b77 (patch)
treeec34949a2d8b022b854acb0e885552c8fc0dd5ff /Programs/_freeze_importlib.c
parente65ec491fbaa14db61a6559eb269733616b0e7f0 (diff)
downloadcpython-0c90d6f75931da4fec84d06c2efe9dd94bb96b77.zip
cpython-0c90d6f75931da4fec84d06c2efe9dd94bb96b77.tar.gz
cpython-0c90d6f75931da4fec84d06c2efe9dd94bb96b77.tar.bz2
[3.7] bpo-34247: Fix Python 3.7 initialization (#8659)
* -X dev: it is now possible to override the memory allocator using PYTHONMALLOC even if the developer mode is enabled. * Add _Py_InitializeFromConfig() * Add _Py_Initialize_ReadEnvVars() to set global configuration variables from environment variables * Fix the code to initialize Python: Py_Initialize() now also reads environment variables * _Py_InitializeCore() can now be called twice: the second call only replaces the configuration. * Write unit tests on Py_Initialize() and the different ways to configure Python * The isolated mode now always sets Py_IgnoreEnvironmentFlag and Py_NoUserSiteDirectory to 1. * pymain_read_conf() now saves/restores the configuration if the encoding changed
Diffstat (limited to 'Programs/_freeze_importlib.c')
-rw-r--r--Programs/_freeze_importlib.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/Programs/_freeze_importlib.c b/Programs/_freeze_importlib.c
index b8b630c..7de641e 100644
--- a/Programs/_freeze_importlib.c
+++ b/Programs/_freeze_importlib.c
@@ -74,18 +74,25 @@ main(int argc, char *argv[])
}
text[text_size] = '\0';
+ _PyCoreConfig config = _PyCoreConfig_INIT;
+ config.program_name = L"./_freeze_importlib";
+ /* Don't install importlib, since it could execute outdated bytecode. */
+ config._disable_importlib = 1;
+
Py_NoUserSiteDirectory++;
Py_NoSiteFlag++;
Py_IgnoreEnvironmentFlag++;
Py_FrozenFlag++;
- Py_SetProgramName(L"./_freeze_importlib");
- /* Don't install importlib, since it could execute outdated bytecode. */
- _PyInitError err = _Py_InitializeEx_Private(1, 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. */
if (_Py_INIT_FAILED(err)) {
_Py_FatalInitError(err);
}
+
if (strstr(inpath, "_external") != NULL) {
is_bootstrap = 0;
}