[New-bugs-announce] [issue33405] PYTHONCOERCECLOCALE no longer being respected

anthony shaw report at bugs.python.org
Wed May 2 02:18:14 EDT 2018


New submission from anthony shaw <anthony.p.shaw at gmail.com>:

observing a behaviour on Python 3.7 b2 that doesn't match what's documented in PEP 538

PEP 538 states that the locale coercion behaviour can be disabled through the PYTHONCOERCECLOCALE environment variable.
I would then expect the stdin encoding to be the same as Python 3.6 when the C locale is specified with no encoding value. 

bash-3.2$ LANG=C python3.6 -c "import sys; print(sys.stdin.encoding)"
US-ASCII
bash-3.2$ LANG=C python3.7 -c "import sys; print(sys.stdin.encoding)"
utf-8
bash-3.2$ PYTHONCOERCECLOCALE=0 LANG=C python3.7 -c "import sys; print(sys.stdin.encoding)"
utf-8

LC_ALL is not set

bash-3.2$ locale
LANG="C"
LC_COLLATE="C"
LC_CTYPE="C"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=

Trying to dig into the reason why the env flag isn't disabling the behaviour I found some subsequent changes after the PEP which look to have broken the original implementation behaviour.

https://github.com/python/cpython/commit/9454060e84a669dde63824d9e2fcaf295e34f687

----------
messages: 316045
nosy: anthony shaw
priority: normal
severity: normal
status: open
title: PYTHONCOERCECLOCALE no longer being respected
type: behavior
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33405>
_______________________________________


More information about the New-bugs-announce mailing list