Author vstinner
Recipients ezio.melotti, vstinner
Date 2012-11-11.22:14:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1352672055.11.0.23985291602.issue16455@psf.upfronthosting.co.za>
In-reply-to
Content
On FreeBSD and OpenIndiana, sys.getfilesystemencoding() is 'ascii' when the locale is not set, whereas the locale encoding is ISO-8859-1.

This inconsistency causes different issue. For example, os.fsencode(sys.argv[1]) fails if the argument is not ASCII because sys.argv are decoded from the locale encoding (by _Py_char2wchar()).

sys.getfilesystemencoding() is 'ascii' because nl_langinfo(CODESET) is used to to get the locale encoding and nl_langinfo(CODESET) announces ASCII (or an alias of this encoding).

Python should detect this case and set sys.getfilesystemencoding() to 'iso8859-1' if the locale encoding is 'iso8859-1' whereas nl_langinfo(CODESET) announces ASCII. We can for example decode b'\xe9' with mbstowcs() and check if it fails or if the result is U+00E9.
History
Date User Action Args
2012-11-11 22:14:15vstinnersetrecipients: + vstinner, ezio.melotti
2012-11-11 22:14:15vstinnersetmessageid: <1352672055.11.0.23985291602.issue16455@psf.upfronthosting.co.za>
2012-11-11 22:14:15vstinnerlinkissue16455 messages
2012-11-11 22:14:14vstinnercreate