| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
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.
|
I tested manually the PR on Fedora 29. Without the fix: $ LANG=en_IN ./python -m test test_re
...
test test_re failed -- Traceback (most recent call last):
File "/home/vstinner/prog/python/master/Lib/test/test_re.py", line 1576, in test_locale_flag
self.assertTrue(pat.match(bletter))
AssertionError: None is not true
...
Tests result: FAILURE
With the fix: $ LANG=en_IN ./python -m test test_re ... Tests result: SUCCESS |
Sorry, something went wrong.
|
I can confirm the issue and the PR fixes the issue. But would like to know the difference between this PR and #149 since they both seem to return the same result but #149 ended up breaking Windows and had to be reverted with #554 meanwhile current PR works with windows CI. karthi@ubuntu-s-1vcpu-1gb-blr1-01:~/cpython$ LANG=en_IN LC_ALL=en_IN ./python -c 'import locale; print(locale.getpreferredencoding(False))' UTF-8 karthi@ubuntu-s-1vcpu-1gb-blr1-01:~/cpython$ LANG=en_IN LC_ALL=en_IN ./python -c 'import locale; print(locale.getpreferredencoding())' UTF-8 |
Sorry, something went wrong.
Honestly, I don't know: The two Windows CIs passed on this PR. I also tested manually the PR on my Windows VM and it passed. |
Sorry, something went wrong.
|
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7. |
Sorry, something went wrong.
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. (cherry picked from commit ab71f8b) Co-authored-by: Victor Stinner <vstinner@redhat.com>
|
GH-12108 is a backport of this pull request to the 3.7 branch. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
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.
https://bugs.python.org/issue29571