]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-133711: Fix test_readline.test_nonascii() for UTF-8 Mode (GH-134841) (...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 28 May 2025 16:10:37 +0000 (18:10 +0200)
committerGitHub <noreply@github.com>
Wed, 28 May 2025 16:10:37 +0000 (16:10 +0000)
gh-133711: Fix test_readline.test_nonascii() for UTF-8 Mode (GH-134841)

Skip the test if the Python UTF-8 Mode is enabled and the LC_CTYPE
encoding is not UTF-8.
(cherry picked from commit 4635115c3f1495fa20e553937df37861fffa7054)

Co-authored-by: Victor Stinner <vstinner@python.org>
Lib/test/test_readline.py

index b9d082b3597f131a2d3a76aebeef0e1370c5b6d9..45192fe508270ddb13dadb2a19838c90f506e878 100644 (file)
@@ -1,6 +1,7 @@
 """
 Very minimal unittests for parts of the readline module.
 """
+import codecs
 import locale
 import os
 import sys
@@ -231,6 +232,13 @@ print("History length:", readline.get_current_history_length())
             # writing and reading non-ASCII bytes into/from a TTY works, but
             # readline or ncurses ignores non-ASCII bytes on read.
             self.skipTest(f"the LC_CTYPE locale is {loc!r}")
+        if sys.flags.utf8_mode:
+            encoding = locale.getencoding()
+            encoding = codecs.lookup(encoding).name  # normalize the name
+            if encoding != "utf-8":
+                # gh-133711: The Python UTF-8 Mode ignores the LC_CTYPE locale
+                # and always use the UTF-8 encoding.
+                self.skipTest(f"the LC_CTYPE encoding is {encoding!r}")
 
         try:
             readline.add_history("\xEB\xEF")