bpo-34170: _PyCoreConfig_Read() don't replace coerce_c_locale by vstinner · Pull Request #8658 · python/cpython
/* If Py_SetProgramName() was called, use its value */ const wchar_t *program_name = _Py_path_config.program_name; if (program_name != NULL) {
const char *env = _PyCoreConfig_GetEnv(config, "PYTHONCOERCECLOCALE"); if (env) { if (strcmp(env, "0") == 0) { config->coerce_c_locale = 0; } else if (strcmp(env, "warn") == 0) { config->coerce_c_locale_warn = 1; } else { config->coerce_c_locale = 1; if (config->coerce_c_locale < 0) { const char *env = _PyCoreConfig_GetEnv(config, "PYTHONCOERCECLOCALE"); if (env) { if (strcmp(env, "0") == 0) { config->coerce_c_locale = 0; } else if (strcmp(env, "warn") == 0) { config->coerce_c_locale_warn = 1; } else { config->coerce_c_locale = 1; } } }
if (_Py_LegacyLocaleDetected()) { /* POSIX locale: enable C locale coercion and UTF-8 Mode */ if (config->utf8_mode < 0) {
config_init_locale(config); if (config->utf8_mode < 0 || config->coerce_c_locale < 0) { config_init_locale(config); }
if (config->_install_importlib) { err = _PyCoreConfig_InitPathConfig(config);