◐ Shell
clean mode source ↗

bpo-29571: Fix test_re.test_locale_flag() by vstinner · Pull Request #12099 · python/cpython

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.

4383

4383 approved these changes Feb 28, 2019

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request

Feb 28, 2019
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>