diff options
author | 2019-05-17 22:44:16 +0200 | |
---|---|---|
committer | 2019-05-17 22:44:16 +0200 | |
commit | bcfbbd704646622e919c1306a91fba61d603483d (patch) | |
tree | 51238f56ba837c49330424bd995b2de71b5a5a48 /Programs | |
parent | bpo-36782: Created C API wrappers and added missing tests for functions in th... (diff) | |
download | cpython-bcfbbd704646622e919c1306a91fba61d603483d.tar.gz cpython-bcfbbd704646622e919c1306a91fba61d603483d.tar.bz2 cpython-bcfbbd704646622e919c1306a91fba61d603483d.zip |
bpo-36945: Add _PyPreConfig.configure_locale (GH-13368)
_PyPreConfig_InitIsolatedConfig() sets configure_locale to 0 to
prevent Python to modify the LC_CTYPE locale. In that case,
coerce_c_locale an coerce_c_locale_warn are set to 0 as well.
Diffstat (limited to 'Programs')
-rw-r--r-- | Programs/_testembed.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/Programs/_testembed.c b/Programs/_testembed.c index e6896966f5..000b2fcec9 100644 --- a/Programs/_testembed.c +++ b/Programs/_testembed.c @@ -788,6 +788,33 @@ static int init_python_config(void) } +static int init_dont_configure_locale(void) +{ + _PyInitError err; + + _PyPreConfig preconfig = _PyPreConfig_INIT; + preconfig.configure_locale = 0; + preconfig.coerce_c_locale = 1; + preconfig.coerce_c_locale_warn = 1; + + err = _Py_PreInitialize(&preconfig); + if (_Py_INIT_FAILED(err)) { + _Py_ExitInitError(err); + } + + _PyCoreConfig config = _PyCoreConfig_INIT; + config.program_name = L"./_testembed"; + err = _Py_InitializeFromConfig(&config); + if (_Py_INIT_FAILED(err)) { + _Py_ExitInitError(err); + } + + dump_config(); + Py_Finalize(); + return 0; +} + + static int init_dev_mode(void) { _PyCoreConfig config; @@ -966,6 +993,7 @@ static struct TestCase TestCases[] = { { "init_env", test_init_env }, { "init_env_dev_mode", test_init_env_dev_mode }, { "init_env_dev_mode_alloc", test_init_env_dev_mode_alloc }, + { "init_dont_configure_locale", init_dont_configure_locale }, { "init_dev_mode", init_dev_mode }, { "init_isolated_flag", init_isolated_flag }, { "init_isolated_config", init_isolated_config }, |