Skip to content

Conversation

@vstinner
Copy link
Member

@vstinner vstinner commented Aug 28, 2018

The POSIX locale now also enables the UTF-8 Mode.

Moreover, Python now also forces the ASCII encoding on FreeBSD and
Solaris if the LC_CTYPE locale is "POSIX", nl_langinfo(CODESET)
announces an ASCII encoding, but mbstowcs() uses Latin1 encoding
instead of ASCII.

https://bugs.python.org/issue34527

Changes:

* The UTF-8 Mode is now also enabled by the "POSIX" locale, not only
  by the "C" locale.
* On FreeBSD, Py_DecodeLocale() and Py_EncodeLocale() now also forces
  the ASCII encoding if the LC_CTYPE locale is "POSIX", not only if
  the LC_CTYPE locale is "C".
* test_utf8_mode.test_cmd_line() checks also that the command line
  arguments are decoded from UTF-8 when the the UTF-8 Mode is enabled
  with POSIX locale or C locale.
@vstinner vstinner merged commit 5cb2589 into python:master Aug 28, 2018
@vstinner vstinner deleted the freebsd_posix_locale branch August 28, 2018 10:35
@miss-islington
Copy link
Contributor

Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖

@miss-islington
Copy link
Contributor

Sorry, @vstinner, I could not cleanly backport this to 3.7 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 5cb258950ce9b69b1f65646431c464c0c17b1510 3.7

@bedevere-bot
Copy link

GH-8974 is a backport of this pull request to the 3.7 branch.

vstinner added a commit that referenced this pull request Aug 28, 2018
* The UTF-8 Mode is now also enabled by the "POSIX" locale, not only
  by the "C" locale.
* On FreeBSD, Py_DecodeLocale() and Py_EncodeLocale() now also forces
  the ASCII encoding if the LC_CTYPE locale is "POSIX", not only if
  the LC_CTYPE locale is "C".
* test_utf8_mode.test_cmd_line() checks also that the command line
  arguments are decoded from UTF-8 when the the UTF-8 Mode is enabled
  with POSIX locale or C locale.

(cherry picked from commit 5cb2589)
@ncoghlan
Copy link
Contributor

Oops, I'd missed that I'd updated the locale coercion check to fire in this case, but not the UTF-8 mode activation (in the event that locale coercion fails, or is switched off). Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants