bpo-30647: Check nl_langinfo(CODESET) in locale coercion by ncoghlan · Pull Request #2374 · python/cpython
- On some versions of FreeBSD, setting the "UTF-8" locale succeeds, but a subsequent "nl_langinfo(CODESET)" fails - adding a check for this in the coercion logic means that coercion will happen on systems where this check succeeds, and will be skipped otherwise - that way CPython should automatically adapt to changes in platform behaviour, rather than needing a new release to enable coercion at build time - this also allows UTF-8 to be re-enabled as a coercion target, restoring the locale coercion behaviour on Mac OS X
ncoghlan
changed the title
bpo-30647: Check nl_langinfo(CODESET) in locale coercion
WIP: bpo-30647: Check nl_langinfo(CODESET) in locale coercion
The problem with dynamically adaptive tests is that they can sometimes pass without actually testing anything useful. On Linux and Mac OS X, if setlocale works, we also expect nl_langinfo(CODESET) to *always* work for the coercion target locales. The tests now reflect this by always assuming the target locale will work if setlocale succeeds when running on Linux or Mac OS X.
Saving and restoring the environment when nl_langinfo fails doesn't work as intended on at least FreeBSD, and potentially other systems as well. Configuring the locale from the environment in this case does the right thing (since we make the exact same call later on in Py_Initialize anyway)
ncoghlan
changed the title
WIP: bpo-30647: Check nl_langinfo(CODESET) in locale coercion
bpo-30647: Check nl_langinfo(CODESET) in locale coercion
ncoghlan
deleted the
bpo-30647-skip-coercion-if-nl-langinfo-fails
branch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters