Skip to content

Commit aa0f6dc

Browse files
miss-islingtonvstinner
authored andcommitted
bpo-13886: Skip PTY non-ASCII tests if readline is loaded (pythonGH-30631) (pythonGH-30635)
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. (cherry picked from commit ad6e640) Co-authored-by: Victor Stinner <[email protected]> Co-authored-by: Victor Stinner <[email protected]>
1 parent d10941e commit aa0f6dc

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
@@ -1980,12 +1980,24 @@ def test_input_tty(self):
19801980
# is different and invokes GNU readline if available).
19811981
self.check_input_tty("prompt", b"quux")
19821982

1983+
def skip_if_readline(self):
1984+
# bpo-13886: When the readline module is loaded, PyOS_Readline() uses
1985+
# the readline implementation. In some cases, the Python readline
1986+
# callback rlhandler() is called by readline with a string without
1987+
# non-ASCII characters. Skip tests on non-ASCII characters if the
1988+
# readline module is loaded, since test_builtin is not intented to test
1989+
# the readline module, but the builtins module.
1990+
if 'readline' in sys.modules:
1991+
self.skipTest("the readline module is loaded")
1992+
19831993
def test_input_tty_non_ascii(self):
1984-
# Check stdin/stdout encoding is used when invoking GNU readline
1994+
self.skip_if_readline()
1995+
# Check stdin/stdout encoding is used when invoking PyOS_Readline()
19851996
self.check_input_tty("prompté", b"quux\xe9", "utf-8")
19861997

19871998
def test_input_tty_non_ascii_unicode_errors(self):
1988-
# Check stdin/stdout error handler is used when invoking GNU readline
1999+
self.skip_if_readline()
2000+
# Check stdin/stdout error handler is used when invoking PyOS_Readline()
19892001
self.check_input_tty("prompté", b"quux\xe9", "ascii")
19902002

19912003
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)