STINNER Victor added the comment:

> I think that Py_FileSystemDefaultEncoding should get updated when 
> locale.setlocale() is run automatically

This is not a good idea. The two following expressions must be True on UNIX:
os.fsencode(os.fsdecode(name)) == name
os.fsdecode(os.fsencode(name)) == name

Said differently: if you change the filesystem encoding, you cannot
encode or decode (depending on the type, str or bytes) back the
filename.

For example, sys.path is a list of filenames filled in an early stage
of Python initialization. If you change the filesystem encoding after
this list is filled, you may fail to import modules.

See also this thread:
http://mail.python.org/pipermail/python-dev/2010-October/104509.html

--

If you want to change the locale encoding, please do it outside Python
(before running Python), and then don't change it again! Example on
Ubuntu:

$ LC_CTYPE=fr_FR.iso885915@euro python -c 'import sys;
print(sys.getfilesystemencoding())'
ISO-8859-15

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue16162>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to