]> granicus.if.org Git - python/commitdiff
[3.6] bpo-29571: Use correct locale encoding in test_re (#149) (#153)
authorNick Coghlan <ncoghlan@gmail.com>
Sun, 19 Feb 2017 04:33:35 +0000 (10:03 +0530)
committerGitHub <noreply@github.com>
Sun, 19 Feb 2017 04:33:35 +0000 (10:03 +0530)
``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.

Lib/test/test_re.py
Misc/NEWS

index b945cf094e99c17df81835e9f03196ada32b569d..a506b98be4aeb2541d55871b62e4e9857995c896 100644 (file)
@@ -1402,7 +1402,7 @@ class ReTests(unittest.TestCase):
 
     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:
index 5f682e5d8fb4a4821846560238c144fa23512424..b631fde8e52e0dcf2b86fde5c438ac70de01d901 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -202,6 +202,11 @@ Documentation
 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 #28950: Disallow -j0 to be combined with -T/-l in regrtest
   command line arguments.