Skip to content

Commit 4635115

Browse files
authored
gh-133711: Fix test_readline.test_nonascii() for UTF-8 Mode (#134841)
Skip the test if the Python UTF-8 Mode is enabled and the LC_CTYPE encoding is not UTF-8.
1 parent d9ec0ee commit 4635115

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Lib/test/test_readline.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Very minimal unittests for parts of the readline module.
33
"""
4+
import codecs
45
import locale
56
import os
67
import sys
@@ -231,6 +232,13 @@ def test_nonascii(self):
231232
# writing and reading non-ASCII bytes into/from a TTY works, but
232233
# readline or ncurses ignores non-ASCII bytes on read.
233234
self.skipTest(f"the LC_CTYPE locale is {loc!r}")
235+
if sys.flags.utf8_mode:
236+
encoding = locale.getencoding()
237+
encoding = codecs.lookup(encoding).name # normalize the name
238+
if encoding != "utf-8":
239+
# gh-133711: The Python UTF-8 Mode ignores the LC_CTYPE locale
240+
# and always use the UTF-8 encoding.
241+
self.skipTest(f"the LC_CTYPE encoding is {encoding!r}")
234242

235243
try:
236244
readline.add_history("\xEB\xEF")

0 commit comments

Comments
 (0)