[Python-Dev] Add a new "locale" codec?
Stephen J. Turnbull
stephen at xemacs.org
Fri Feb 10 09:54:36 CET 2012
Victor Stinner writes:
> > If this is needed, it should be spelled "os.getlocaleencoding()" (or
> > "sys.getlocaleencoding()"?)
>
> There is already a locale.getpreferredencoding(False) function which
> give your the current locale encoding. The problem is that the current
> locale encoding may change and so you have to get the new value each
> time than you would like to encode or decode data.
How can that happen if the programmer (or a module she has imported)
isn't messing with the locale? If the programmer is messing with the
locale, really they need to be careful. A magic codec whose encoding
changes *within* a process is an accident waiting to happen.
Do you have a real use case for the "'locale' codec's encoding changes
with the locale within process" feature?
More information about the Python-Dev
mailing list