bpo-36763: Fix C locale coercion by vstinner · Pull Request #13444 · python/cpython

Conversation

@vstinner

  • Fix _Py_LegacyLocaleDetected(): don't attempt to coerce the
    C locale if LC_ALL environment variable is set. Add 'warn'
    parameter: emit_stderr_warning_for_legacy_locale() must check for
    the LC_ALL env var.
  • _PyPreConfig_Write() sets coerce_c_locale to 0 if
    _Py_CoerceLegacyLocale() fails.

Altogether, _PyRuntime.preconfig.coerce_c_locale can now be used to
check if the C locale has been coerced.

https://bugs.python.org/issue36763

* Fix _Py_LegacyLocaleDetected(): don't attempt to coerce the
  C locale if LC_ALL environment variable is set. Add 'warn'
  parameter: emit_stderr_warning_for_legacy_locale() must check for
  the LC_ALL env var.
* _PyPreConfig_Write() sets coerce_c_locale to 0 if
  _Py_CoerceLegacyLocale() fails.

Altogether, _PyRuntime.preconfig.coerce_c_locale can now be used to
check if the C locale has been coerced.

@vstinner

cc @ncoghlan: this PR doesn't change the Python behavior, it only changes _PyRuntime.preconfig.coerce_c_locale when LC_ALL env var is set, or if coercion the C locale fails. _PyRuntime.preconfig.coerce_c_locale is set to 0 in this case, instead of 2.

@ncoghlan

Labels