summaryrefslogtreecommitdiffstats
path: root/Python/preconfig.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-03-27 12:40:14 (GMT)
committerGitHub <noreply@github.com>2019-03-27 12:40:14 (GMT)
commit5ac27a50ff2b42216746fedc0522a92c53089bb3 (patch)
tree5fbf53a0b5e47f6704f01397de3e01799bf87d41 /Python/preconfig.c
parent364f0b0f19cc3f0d5e63f571ec9163cf41c62958 (diff)
downloadcpython-5ac27a50ff2b42216746fedc0522a92c53089bb3.zip
cpython-5ac27a50ff2b42216746fedc0522a92c53089bb3.tar.gz
cpython-5ac27a50ff2b42216746fedc0522a92c53089bb3.tar.bz2
bpo-36444: Rework _Py_InitializeFromConfig() API (GH-12576)
Diffstat (limited to 'Python/preconfig.c')
-rw-r--r--Python/preconfig.c50
1 files changed, 22 insertions, 28 deletions
diff --git a/Python/preconfig.c b/Python/preconfig.c
index ce63ef0..011ed53 100644
--- a/Python/preconfig.c
+++ b/Python/preconfig.c
@@ -148,22 +148,6 @@ _PyPreCmdline_SetPreConfig(const _PyPreCmdline *cmdline, _PyPreConfig *config)
}
-static void
-_PyPreCmdline_GetCoreConfig(_PyPreCmdline *cmdline, const _PyCoreConfig *config)
-{
-#define COPY_ATTR(ATTR) \
- if (config->ATTR != -1) { \
- cmdline->ATTR = config->ATTR; \
- }
-
- COPY_ATTR(isolated);
- COPY_ATTR(use_environment);
- COPY_ATTR(dev_mode);
-
-#undef COPY_ATTR
-}
-
-
int
_PyPreCmdline_SetCoreConfig(const _PyPreCmdline *cmdline, _PyCoreConfig *config)
{
@@ -231,17 +215,12 @@ precmdline_parse_cmdline(_PyPreCmdline *cmdline)
_PyInitError
_PyPreCmdline_Read(_PyPreCmdline *cmdline,
- const _PyPreConfig *preconfig,
- const _PyCoreConfig *coreconfig)
+ const _PyPreConfig *preconfig)
{
if (preconfig) {
_PyPreCmdline_GetPreConfig(cmdline, preconfig);
}
- if (coreconfig) {
- _PyPreCmdline_GetCoreConfig(cmdline, coreconfig);
- }
-
_PyInitError err = precmdline_parse_cmdline(cmdline);
if (_Py_INIT_FAILED(err)) {
return err;
@@ -373,6 +352,23 @@ fail:
}
+void
+_PyCoreConfig_GetCoreConfig(_PyPreConfig *config,
+ const _PyCoreConfig *core_config)
+{
+#define COPY_ATTR(ATTR) \
+ if (core_config->ATTR != -1) { \
+ config->ATTR = core_config->ATTR; \
+ }
+
+ COPY_ATTR(isolated);
+ COPY_ATTR(use_environment);
+ COPY_ATTR(dev_mode);
+
+#undef COPY_ATTR
+}
+
+
static void
_PyPreConfig_GetGlobalConfig(_PyPreConfig *config)
{
@@ -640,12 +636,11 @@ preconfig_init_allocator(_PyPreConfig *config)
static _PyInitError
-preconfig_read(_PyPreConfig *config, _PyPreCmdline *cmdline,
- const _PyCoreConfig *coreconfig)
+preconfig_read(_PyPreConfig *config, _PyPreCmdline *cmdline)
{
_PyInitError err;
- err = _PyPreCmdline_Read(cmdline, config, coreconfig);
+ err = _PyPreCmdline_Read(cmdline, config);
if (_Py_INIT_FAILED(err)) {
return err;
}
@@ -692,8 +687,7 @@ preconfig_read(_PyPreConfig *config, _PyPreCmdline *cmdline,
- Py_xxx global configuration variables
- the LC_CTYPE locale */
_PyInitError
-_PyPreConfig_Read(_PyPreConfig *config, const _PyArgv *args,
- const _PyCoreConfig *coreconfig)
+_PyPreConfig_Read(_PyPreConfig *config, const _PyArgv *args)
{
_PyInitError err;
@@ -756,7 +750,7 @@ _PyPreConfig_Read(_PyPreConfig *config, const _PyArgv *args,
Py_LegacyWindowsFSEncodingFlag = config->legacy_windows_fs_encoding;
#endif
- err = preconfig_read(config, &cmdline, coreconfig);
+ err = preconfig_read(config, &cmdline);
if (_Py_INIT_FAILED(err)) {
goto done;
}