Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Merged
vstinner merged 2 commits into
python:3.7python/cpython:3.7from
vstinner:test_locale_flag37Copy head branch name to clipboard
Mar 5, 2019
Merged

[3.7] bpo-29571: Fix test_re.test_locale_flag()#12178
vstinner merged 2 commits into
python:3.7python/cpython:3.7from
vstinner:test_locale_flag37Copy head branch name to clipboard

Conversation

@vstinner

@vstinner vstinner commented Mar 5, 2019

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

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 vstinner merged commit 279657b into python:3.7 Mar 5, 2019
@vstinner vstinner deleted the test_locale_flag37 branch March 5, 2019 15:17
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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.