On 7 December 2017 at 08:20, Victor Stinner <victor.stinner at gmail.com> wrote:
> 2017-12-06 23:07 GMT+01:00 Antoine Pitrou <solipsis at pitrou.net>:
>> One question: how do you plan to test for the POSIX locale?
>> I'm not sure. I will probably rely on Nick for that ;-) Nick already
> implemented this exact check for his PEP 538 which is already
> implemented in Python 3.7.
>> I already implemented the PEP 540:
>>https://bugs.python.org/issue29240>https://github.com/python/cpython/pull/855>> Right now, my implementation uses:
>> char *ctype = _PyMem_RawStrdup(setlocale(LC_CTYPE, ""));
> ...
> if (strcmp(ctype, "C") == 0) ...
We have a private helper for this as a result of the PEP 538
implementation: _Py_LegacyLocaleDetected()
Details are in the source code at
https://github.com/python/cpython/blob/master/Python/pylifecycle.c#L345
As per my comment there, and Jakub Wilk's post to this thread, we're
missing a case to also check for the string "POSIX" (which will fix
several of the current locale coercion discrepancies between Linux and
*BSD systems).
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia