[docs] [issue33934] locale.getlocale() seems wrong when the locale is yet unset (python3 on linux)
report at bugs.python.org
Mon Jun 25 06:50:11 EDT 2018
Nick Coghlan <ncoghlan at gmail.com> added the comment:
Ah, part of the confusion is that I misremembered the command we run implicitly during startup - it's only `setlocale(LC_CTYPE, "")`, not `setlocale(LC_ALL, "")`.
However, the default category for `locale.getlocale()` is `LC_CTYPE`, so it reports the text encoding locale configured during startup, not the C level default.
The difference on Windows is expected - the startup code that implicitly runs `setlocale(LC_CTYPE, "")` doesn't get compiled in there.
So I think we have a few different potential ways of viewing this bug report:
1. As a docs issue, where we advise users to run `locale.getlocale(locale.LC_MESSAGES)` to find out whether or not a specific locale really has been configured (vs the interpreter's default text encoding change that runs implicitly on startup)
2. As a defaults change for 3.8+, where we switch `locale.getlocale()` over to checking `locale.LC_MESSAGES` instead of `locale.LC_CTYPES`, since the interpreter always sets the latter on startup, so it doesn't convey much useful information.
3. As (1) for maintenance releases, and as (2) for 3.8+
Python tracker <report at bugs.python.org>
More information about the docs