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

Skip to content

Commit ace5c0f

Browse files
authored
bpo-29571: Use correct locale encoding in test_re (#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 1b3d88e commit ace5c0f

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
@@ -1399,7 +1399,7 @@ def test_ascii_and_unicode_flag(self):
13991399

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

Misc/NEWS

+5
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,11 @@ Tools/Demos
801801
Tests
802802
-----
803803

804+
- Issue #29571: to match the behaviour of the ``re.LOCALE`` flag,
805+
test_re.test_locale_flag now uses ``locale.getpreferredencoding(False)`` to
806+
determine the candidate encoding for the test regex (allowing it to correctly
807+
skip the test when the default locale encoding is a multi-byte encoding)
808+
804809
- Issue #24932: Use proper command line parsing in _testembed
805810

806811
- Issue #28950: Disallow -j0 to be combined with -T/-l in regrtest

0 commit comments

Comments
 (0)