Skip to content

Commit

Permalink
[3.5] bpo-29571: Use correct locale encoding in test_re (#149) (#154)
Browse files Browse the repository at this point in the history
``local.getlocale(locale.LC_CTYPE)`` and
``locale.getpreferredencoding(False)`` may give different answers
in some cases (such as the ``en_IN`` locale).

``re.LOCALE`` uses the latter, so update the test case to match.
  • Loading branch information
ncoghlan authored Feb 19, 2017
1 parent 5e04dfe commit 760f596
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Lib/test/test_re.py
Original file line number Diff line number Diff line change
Expand Up @@ -1334,7 +1334,7 @@ def test_ascii_and_unicode_flag(self):

def test_locale_flag(self):
import locale
_, enc = locale.getlocale(locale.LC_CTYPE)
enc = locale.getpreferredencoding(False)
# Search non-ASCII letter
for i in range(128, 256):
try:
Expand Down
8 changes: 8 additions & 0 deletions Misc/NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ Documentation

- Issue #29349: Fix Python 2 syntax in code for building the documentation.

Tests
-----

- Issue #29571: to match the behaviour of the ``re.LOCALE`` flag,
test_re.test_locale_flag now uses ``locale.getpreferredencoding(False)`` to
determine the candidate encoding for the test regex (allowing it to correctly
skip the test when the default locale encoding is a multi-byte encoding)


What's New in Python 3.5.3?
===========================
Expand Down

0 comments on commit 760f596

Please sign in to comment.