mirror of
https://github.com/python/cpython.git
synced 2026-01-06 15:32:22 +00:00
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.
This commit is contained in:
parent
98ff4d5fb6
commit
bcfbbd7046
4 changed files with 82 additions and 10 deletions
|
|
@ -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 },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue