Skip to content

Commit 0c66eb0

Browse files
committed
[3.6] bpo-29571: Use correct locale encoding in test_re (python#149)
``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.
1 parent b300c66 commit 0c66eb0

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Lib/test/test_re.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1402,7 +1402,7 @@ def test_ascii_and_unicode_flag(self):
14021402

14031403
def test_locale_flag(self):
14041404
import locale
1405-
_, enc = locale.getlocale(locale.LC_CTYPE)
1405+
enc = locale.getpreferredencoding(False)
14061406
# Search non-ASCII letter
14071407
for i in range(128, 256):
14081408
try:

Misc/NEWS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,11 @@ Documentation
200200
Tests
201201
-----
202202

203+
- Issue #29571: to match the behaviour of the ``re.LOCALE`` flag,
204+
test_re.test_locale_flag now uses ``locale.getpreferredencoding(False)`` to
205+
determine the candidate encoding for the test regex (allowing it to correctly
206+
skip the test when the default locale encoding is a multi-byte encoding)
207+
203208
- Issue #28950: Disallow -j0 to be combined with -T/-l in regrtest
204209
command line arguments.
205210

0 commit comments

Comments
 (0)