[issue30338] LC_ALL=en_US + io.open() => LookupError: (osx)

STINNER Victor report at bugs.python.org
Fri May 12 05:53:58 EDT 2017


STINNER Victor added the comment:

> Note that _pyio uses locale.getpreferedencoding(), not locale.getpreferredencoding(False).

Oh, it's a difference between Python 2.7 and Python 3.

Python 3 calls setlocale(LC_CTYPE, "") at startup, so locale.getpreferredencoding(False) can be used in Python 3.

Python 2.7 requires to call locale.getpreferredencoding() to get the encoding of the *user* locale.

----------

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


More information about the Python-bugs-list mailing list