Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0683d68

Browse files
authored
[3.6] bpo-29571: Use correct locale encoding in test_re (python#149) (python#153)
``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 d372cda commit 0683d68

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Lib/test/test_re.py

+1-1
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

+5
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,11 @@ Documentation
202202
Tests
203203
-----
204204

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

0 commit comments

Comments
 (0)