diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py index 1d7fb76c383396..92d2c1386de464 100644 --- a/Lib/test/test_re.py +++ b/Lib/test/test_re.py @@ -1399,7 +1399,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: diff --git a/Misc/NEWS b/Misc/NEWS index 1422627b9052a2..53f1dc6d7f0c4f 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -801,6 +801,11 @@ Tools/Demos 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) + - Issue #24932: Use proper command line parsing in _testembed - Issue #28950: Disallow -j0 to be combined with -T/-l in regrtest