summaryrefslogtreecommitdiffstats
path: root/Programs
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-07-25 00:49:17 (GMT)
committerGitHub <noreply@github.com>2018-07-25 00:49:17 (GMT)
commit1dc6e3906acb81163725e98378bf4d1bd1ce771a (patch)
tree8aa562d0a219b6880ed4757ac6ae2367024b3b76 /Programs
parent6cf8255912c36fec6f87f62513034d0818f61390 (diff)
downloadcpython-1dc6e3906acb81163725e98378bf4d1bd1ce771a.zip
cpython-1dc6e3906acb81163725e98378bf4d1bd1ce771a.tar.gz
cpython-1dc6e3906acb81163725e98378bf4d1bd1ce771a.tar.bz2
bpo-34170: Add _Py_InitializeFromConfig() (GH-8454)
* If _Py_InitializeCore() is called twice, the second call now copies and apply (partially) the new configuration. * Rename _Py_CommandLineDetails to _PyCmdline * Move more code into pymain_init(). The core configuration created by Py_Main() is new destroyed before running Python to reduce the memory footprint. * _Py_InitializeCore() now returns the created interpreter. _Py_InitializeMainInterpreter() now expects an interpreter. * Remove _Py_InitializeEx_Private(): _freeze_importlib now uses _Py_InitializeFromConfig() * _PyCoreConfig_InitPathConfig() now only computes the path configuration if needed.
Diffstat (limited to 'Programs')
-rw-r--r--Programs/_freeze_importlib.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/Programs/_freeze_importlib.c b/Programs/_freeze_importlib.c
index b8b630c..03e0826 100644
--- a/Programs/_freeze_importlib.c
+++ b/Programs/_freeze_importlib.c
@@ -74,14 +74,20 @@ main(int argc, char *argv[])
}
text[text_size] = '\0';
- Py_NoUserSiteDirectory++;
- Py_NoSiteFlag++;
- Py_IgnoreEnvironmentFlag++;
+ _PyCoreConfig config = _PyCoreConfig_INIT;
+ config.user_site_directory = 0;
+ config.site_import = 0;
+ config.ignore_environment = 1;
+ config.program_name = L"./_freeze_importlib";
+ /* Don't install importlib, since it could execute outdated bytecode. */
+ config._install_importlib = 0;
+ config.install_signal_handlers = 1;
+
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);
}