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

Skip to content

Commit 760f596

Browse files
authored
[3.5] bpo-29571: Use correct locale encoding in test_re (python#149) (python#154)
``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 5e04dfe commit 760f596

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Lib/test/test_re.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1334,7 +1334,7 @@ def test_ascii_and_unicode_flag(self):
13341334

13351335
def test_locale_flag(self):
13361336
import locale
1337-
_, enc = locale.getlocale(locale.LC_CTYPE)
1337+
enc = locale.getpreferredencoding(False)
13381338
# Search non-ASCII letter
13391339
for i in range(128, 256):
13401340
try:

Misc/NEWS

+8
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ Documentation
8787

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

90+
Tests
91+
-----
92+
93+
- Issue #29571: to match the behaviour of the ``re.LOCALE`` flag,
94+
test_re.test_locale_flag now uses ``locale.getpreferredencoding(False)`` to
95+
determine the candidate encoding for the test regex (allowing it to correctly
96+
skip the test when the default locale encoding is a multi-byte encoding)
97+
9098

9199
What's New in Python 3.5.3?
92100
===========================

0 commit comments

Comments
 (0)