[issue30565] PEP 538: default to skipping warning for implicit locale coercion?

STINNER Victor report at bugs.python.org
Wed Jun 14 10:27:14 EDT 2017


STINNER Victor added the comment:

I wrote a PR to remove PEP 538 warnings:
https://github.com/python/cpython/pull/2186

Reference (unpatched):

haypo at selma$ env -i LC_ALL=C ./python -c "import locale; print(locale.getpreferredencoding())"
Python runtime initialized with LC_CTYPE=C (a locale with default ASCII encoding), which may cause Unicode compatibility problems. Using C.UTF-8, C.utf8, or UTF-8 (if available) as alternative Unicode-compatible locales is recommended.
ANSI_X3.4-1968

haypo at selma$ env -i LC_CTYPE=C ./python -c "import locale; print(locale.getpreferredencoding())"
Python detected LC_CTYPE=C: LC_CTYPE coerced to C.UTF-8 (set another locale or PYTHONCOERCECLOCALE=0 to disable this locale coercion behavior).
UTF-8

haypo at selma$ env -i LC_ALL=C ./python -c "import locale; print(locale.getpreferredencoding())"
Python runtime initialized with LC_CTYPE=C (a locale with default ASCII encoding), which may cause Unicode compatibility problems. Using C.UTF-8, C.utf8, or UTF-8 (if available) as alternative Unicode-compatible locales is recommended.
ANSI_X3.4-1968


With my change:

haypo at selma$ env -i ./python -c "import locale; print(locale.getpreferredencoding())"
UTF-8

haypo at selma$ env -i LC_CTYPE=C ./python -c "import locale; print(locale.getpreferredencoding())"
UTF-8

haypo at selma$ env -i LC_ALL=C ./python -c "import locale; print(locale.getpreferredencoding())"
ANSI_X3.4-1968

----------

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


More information about the Python-bugs-list mailing list