[issue11022] locale.setlocale() doesn't change I/O codec, os.environ does

R. David Murray report at bugs.python.org
Tue Feb 1 03:43:24 CET 2011


R. David Murray <rdmurray at bitdance.com> added the comment:

Steffan: I'm not sure what your post means, but I think there is a chance you might be confused about something.  Python should *never* change the locale from the C locale.  A Python *program* can do so, by calling setlocale, but Python itself should not.  This is because when an arbitrary Python program is run, it needs to run in the C locale *unless it chooses otherwise*.  To do anything else would produce a myriad portability problems for any code that is affected by locale settings (especially when the programmer doesn't know that it is so affected).

This is orthogonal to the issue of deciding what encoding to use for various bits of I/O, where Python may need to discover what locale the user has chosen as a default.  It's too bad libc makes this so hard to do safely.

----------
nosy: +r.david.murray

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11022>
_______________________________________


More information about the Python-bugs-list mailing list