summaryrefslogtreecommitdiffstats
path: root/Modules/main.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-05-17 17:01:14 (GMT)
committerGitHub <noreply@github.com>2019-05-17 17:01:14 (GMT)
commitcab5d0741ee6adf2ae9ff5aaafe06b75b4b5bca3 (patch)
tree745b2e08f4a035ffb345e695216934b1a3b6ccda /Modules/main.c
parentb16b4e45923f4e4dfd8e970ae4e6a934faf73b79 (diff)
downloadcpython-cab5d0741ee6adf2ae9ff5aaafe06b75b4b5bca3.zip
cpython-cab5d0741ee6adf2ae9ff5aaafe06b75b4b5bca3.tar.gz
cpython-cab5d0741ee6adf2ae9ff5aaafe06b75b4b5bca3.tar.bz2
bpo-36763: Add _PyCoreConfig_InitPythonConfig() (GH-13388)
Add new functions to get the Python interpreter behavior: * _PyPreConfig_InitPythonConfig() * _PyCoreConfig_InitPythonConfig() Add new functions to get an isolated configuration: * _PyPreConfig_InitIsolatedConfig() * _PyCoreConfig_InitIsolatedConfig() Replace _PyPreConfig_INIT and _PyCoreConfig_INIT with new functions _PyPreConfig_Init() and _PyCoreConfig_Init(). _PyCoreConfig: set configure_c_stdio and parse_argv to 0 by default to behave as Python 3.6 in the default configuration. _PyCoreConfig_Read() no longer sets coerce_c_locale_warn to 1 if it's equal to 0. coerce_c_locale_warn must now be set to -1 (ex: using _PyCoreConfig_InitPythonConfig()) to enable C locale coercion warning. Add unit tests for _PyCoreConfig_InitPythonConfig() and _PyCoreConfig_InitIsolatedConfig(). Changes: * Rename _PyCoreConfig_GetCoreConfig() to _PyPreConfig_GetCoreConfig() * Fix core_read_precmdline(): handle parse_argv=0 * Fix _Py_PreInitializeFromCoreConfig(): pass coreconfig.argv to _Py_PreInitializeFromPyArgv(), except if parse_argv=0
Diffstat (limited to 'Modules/main.c')
-rw-r--r--Modules/main.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/Modules/main.c b/Modules/main.c
index bb103c2..72546a2 100644
--- a/Modules/main.c
+++ b/Modules/main.c
@@ -52,23 +52,28 @@ pymain_init(const _PyArgv *args)
fedisableexcept(FE_OVERFLOW);
#endif
- _PyPreConfig preconfig = _PyPreConfig_INIT;
- /* Set to -1 to enable them depending on the LC_CTYPE locale and the
- environment variables (PYTHONUTF8 and PYTHONCOERCECLOCALE) */
- preconfig.coerce_c_locale = -1;
- preconfig.utf8_mode = -1;
+ _PyPreConfig preconfig;
+ _PyPreConfig_InitPythonConfig(&preconfig);
err = _Py_PreInitializeFromPyArgv(&preconfig, args);
if (_Py_INIT_FAILED(err)) {
return err;
}
+ _PyCoreConfig config;
+ err = _PyCoreConfig_InitPythonConfig(&config);
+ if (_Py_INIT_FAILED(err)) {
+ return err;
+ }
+
/* pass NULL as the config: config is read from command line arguments,
environment variables, configuration files */
if (args->use_bytes_argv) {
- return _Py_InitializeFromArgs(NULL, args->argc, args->bytes_argv);
+ return _Py_InitializeFromArgs(&config,
+ args->argc, args->bytes_argv);
}
else {
- return _Py_InitializeFromWideArgs(NULL, args->argc, args->wchar_argv);
+ return _Py_InitializeFromWideArgs(&config,
+ args->argc, args->wchar_argv);
}
}