[Tutor] locale.set/getlocale asymmetry

eryksun eryksun at gmail.com
Wed Feb 20 13:37:14 CET 2013


On Wed, Feb 20, 2013 at 5:53 AM, Albert-Jan Roskam <fomcl at yahoo.com> wrote:
> There is an asymmetry in getlocale and setlocale. What is returned by
> getlocale cannot be used as argument for setlocale.

getlocale executes localename = _setlocale(category), where _setlocale
wraps the C runtime setlocale. Then it transforms the return string to
a tuple using _parse_localename, which calls locale.normalize. The
latter changes the language and encoding incorrectly on Windows.
Instead, you could save the unparsed locale string: old_locale =
setlocale(LC_ALL).


More information about the Tutor mailing list