Author vstinner
Recipients vstinner
Date 2018-11-28.10:42:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1543401736.44.0.788709270274.issue35336@psf.upfronthosting.co.za>
In-reply-to
Content
PYTHONCOERCECLOCALE=1 should not force C locale coercion, Python should still check if the LC_CTYPE locale is "C".

Bug:

$ ./python -c 'import locale; print(locale.setlocale(locale.LC_CTYPE, None))'
fr_FR.UTF-8
$ PYTHONCOERCECLOCALE=1 ./python -c 'import locale; print(locale.setlocale(locale.LC_CTYPE, None))'
C.UTF-8

It should be fr_FR.UTF-8 as well in the second example :-( It seems to be a regression that I introduced in the middle of my refactoring on the Python initialization.

The bug is around:

static void
config_init_locale(_PyCoreConfig *config)
{
    if (config->coerce_c_locale < 0) {
        /* The C locale enables the C locale coercion (PEP 538) */
        if (_Py_LegacyLocaleDetected()) {
            config->coerce_c_locale = 1;
        }
    }
    ...
}

The 3.7 branch and the 3.7.0 release are affected :-(

$ ./python -V
Python 3.7.0
$ PYTHONCOERCECLOCALE=1 ./python -c 'import locale; print(locale.setlocale(locale.LC_CTYPE, None))'
C.UTF-8
History
Date User Action Args
2018-11-28 10:42:16vstinnersetrecipients: + vstinner
2018-11-28 10:42:16vstinnersetmessageid: <1543401736.44.0.788709270274.issue35336@psf.upfronthosting.co.za>
2018-11-28 10:42:16vstinnerlinkissue35336 messages
2018-11-28 10:42:15vstinnercreate