FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.7] bpo-29571: Fix test_re.test_locale_flag() by vstinner · Pull Request #12178 · python/cpython · GitHub

Repository navigation

[3.7] bpo-29571: Fix test_re.test_locale_flag() - #12178

Merged
vstinner merged 2 commits into
python:3.7from
vstinner:test_locale_flag37
Mar 5, 2019
Merged

vstinner merged 2 commits into
python:3.7from
vstinner:test_locale_flag37

Conversation

vstinner commented Mar 5, 2019 •
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

Use locale.getpreferredencoding() rather than locale.getlocale() to
get the locale encoding. With some locales, locale.getlocale()
returns the wrong encoding.

For example, on Fedora 29, locale.getlocale() returns ISO-8859-1
encoding for the "en_IN" locale, whereas
locale.getpreferredencoding() reports the correct encoding: UTF-8.

On Windows, set temporarily the LC_CTYPE locale to the user preferred
encoding to ensure that it uses the ANSI code page, to be consistent
with locale.getpreferredencoding().

https://bugs.python.org/issue29571

Use locale.getpreferredencoding() rather than locale.getlocale() to
get the locale encoding. With some locales, locale.getlocale()
returns the wrong encoding.

For example, on Fedora 29, locale.getlocale() returns ISO-8859-1
encoding for the "en_IN" locale, whereas
locale.getpreferredencoding() reports the correct encoding: UTF-8.

On Windows, set temporarily the LC_CTYPE locale to the user preferred
encoding to ensure that it uses the ANSI code page, to be consistent
with locale.getpreferredencoding().

vstinner commented Mar 5, 2019

Copy link
Copy Markdown
Member Author

I tested manually the PR on Linux with "LANG=en_IN ./python -m test -v test_re": fail without the change, pass with the change.

I also tested the PR on Windows: test_re pass.

vstinner merged commit 279657b into python:3.7 Mar 5, 2019
vstinner deleted the test_locale_flag37 branch March 5, 2019 15:17
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL