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

Nick Coghlan ncoghlan at gmail.com
Mon Jun 26 00:08:12 EDT 2017


On 12 June 2017 at 22:24, Nick Coghlan <ncoghlan at gmail.com> wrote:
> On 12 June 2017 at 18:56, Victor Stinner <victor.stinner at gmail.com> wrote:
>> 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)."
>
> Note that there's an open issue for this linked from the What's New entry:
>
> * https://docs.python.org/dev/whatsnew/3.7.html#pep-538-legacy-c-locale-coercion
> * https://bugs.python.org/issue30565
>
> I suspect the eventual outcome is going to be dropping that particular
> warning (since it's been problematic for Fedora's 3.6 backport as
> well, and the problems are due to the warning itself, *not* the locale
> coercion), but I'd prefer to keep the notification at least for a
> while (potentially even until alpha 1).
>
> OTOH, I'm also open to being persuaded otherwise if enough folks are
> running into problems with it just while working on CPython (I'd still
> like to turn it back on for alpha 1 even if we turn off in the
> meantime, though).

Following up here for the sake of folks following this thread, but not
all the related issues: with the locale warnings enabled by default,
we(/I) couldn't even get CPython's own test suite to pass reliably
across the full fleet of stable buildbots.

As a result, https://bugs.python.org/issue30565 was implemented in
https://github.com/python/cpython/pull/2260, switching us to an opt-in
warning model where you have to set `PYTHONCOERCECLOCALE=warn` to get
the notifications on stderr both when locale coercion triggers and
when the interpreter runtime itself is initialized in a locale that
would have triggered coercion in the CLI. That then becomes a runtime
debugging switch (akin to `-X faulthandler` or `-X tracemalloc`) for
folks investigating surprising locale-related behaviour in 3.7+,
rather than something we do by default.

The original PEP has also been updated with a note indicating that the
originally accepted approach was found to be impractical:
https://www.python.org/dev/peps/pep-0538/#implementation-notes

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-Dev mailing list