8000 [3.13] gh-133711: Fix test_readline.test_nonascii() for UTF-8 Mode (G… · python/cpython@07d4b63 · GitHub
[go: up one dir, main page]

8000
Skip to content

Commit 07d4b63

Browse files
[3.13] gh-133711: Fix test_readline.test_nonascii() for UTF-8 Mode (GH-134841) (#134852)
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 4635115) Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent a0287bf commit 07d4b63

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
@@ -228,6 +229,13 @@ def test_nonascii(self):
228229
# writing and reading non-ASCII bytes into/from a TTY works, but
229230
# readline or ncurses ignores non-ASCII bytes on read.
230231
self.skipTest(f"the LC_CTYPE locale is {loc!r}")
232+
if sys.flags.utf8_mode:
233+
encoding = locale.getencoding()
234+
encoding = codecs.lookup(encoding).name # normalize the name
235+
if encoding != "utf-8":
236+
# gh-133711: The Python UTF-8 Mode ignores the LC_CTYPE locale
237+
# and always use the UTF-8 encoding.
238+
self.skipTest(f"the LC_CTYPE encoding is {encoding!r}")
231239

232240
try:
233241
readline.add_history("\xEB\xEF")

0 commit comments

Comments
 (0)
0