[Python-Dev] PEP 538 warning at startup: please remove it

Victor Stinner victor.stinner at gmail.com
Mon Jun 12 04:56:31 EDT 2017


Hi,

Nick Coghlan pushed his implementation of his PEP 538: nice! Nice step
forward to UTF-8 everywhere ;-)

I would prefer to not be annoyed by warning messages about encodings
at startup if possible:

"Python detected LC_CTYPE=C: LC_CTYPE coerced to C.UTF-8 (set another
locale or PYTHONCOERCECLOCALE=0 to disable this locale coercion
behavior)."


Python 3.7 is the only programming language that I know that complains
about encoding at startup. Even if my code is 100% valid, PEP 8
compliant, don't emit any warning, etc. I will get the warning. It is
*not* possible to ignore the warning... Like "yeah, I know that my
locale is C, but it's not like I'm able to configure it."

haypo at selma$ export LANG=
haypo at selma$ locale
LANG=
LC_CTYPE="POSIX"
...

haypo at selma$ ./python -c 'print("Hello World!")' # Python 3.7
Python detected LC_CTYPE=C: LC_CTYPE coerced to C.UTF-8 (set another
locale or PYTHONCOERCECLOCALE=0 to disable this locale coercion
behavior).
Hello World!

haypo at selma$ python2 -c 'print("Hello World!")' # Python 2.7
Hello World!

haypo at selma$ perl -e 'print "Hello, world!\n"' # Perl 5.24
Hello, world!

haypo at selma$ ./c   # C
Hello World!

...

Note: I don't consider that 2>/dev/null is a good practice to ignore a
single warning, since it will ignore *all* message written into
stderr, including useful warnings like ResourceWarning or "Exception
ignored ...".

Victor


More information about the Python-Dev mailing list