Skip to content

Commit ad6e640

Browse files
authored
bpo-13886: Skip PTY non-ASCII tests if readline is loaded (GH-30631)
Skip test_builtin PTY tests on non-ASCII characters if the readline module is loaded. The readline module changes input() behavior, but test_builtin is not intented to test the readline module. When the readline module is loaded, PyOS_Readline() uses the readline implementation. In some cases, the Python readline callback rlhandler() is called by readline with a string without non-ASCII characters.
1 parent 42a64c0 commit ad6e640

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

Lib/test/test_builtin.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2090,12 +2090,24 @@ def test_input_tty(self):
20902090
# is different and invokes GNU readline if available).
20912091
self.check_input_tty("prompt", b"quux")
20922092

2093+
def skip_if_readline(self):
2094+
# bpo-13886: When the readline module is loaded, PyOS_Readline() uses
2095+
# the readline implementation. In some cases, the Python readline
2096+
# callback rlhandler() is called by readline with a string without
2097+
# non-ASCII characters. Skip tests on non-ASCII characters if the
2098+
# readline module is loaded, since test_builtin is not intented to test
2099+
# the readline module, but the builtins module.
2100+
if 'readline' in sys.modules:
2101+
self.skipTest("the readline module is loaded")
2102+
20932103
def test_input_tty_non_ascii(self):
2094-
# Check stdin/stdout encoding is used when invoking GNU readline
2104+
self.skip_if_readline()
2105+
# Check stdin/stdout encoding is used when invoking PyOS_Readline()
20952106
self.check_input_tty("prompté", b"quux\xe9", "utf-8")
20962107

20972108
def test_input_tty_non_ascii_unicode_errors(self):
2098-
# Check stdin/stdout error handler is used when invoking GNU readline
2109+
self.skip_if_readline()
2110+
# Check stdin/stdout error handler is used when invoking PyOS_Readline()
20992111
self.check_input_tty("prompté", b"quux\xe9", "ascii")
21002112

21012113
def test_input_no_stdout_fileno(self):
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Skip test_builtin PTY tests on non-ASCII characters if the readline module
2+
is loaded. The readline module changes input() behavior, but test_builtin is
3+
not intented to test the readline module. Patch by Victor Stinner.

0 commit comments

Comments
 (0)