summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-01-17 13:47:21 (GMT)
committerGitHub <noreply@github.com>2022-01-17 13:47:21 (GMT)
commit0fbb9afbddb93408e34bdb7625002374cb2ad68c (patch)
treeef99a80286c655c3417993ba036fad27e308a40f
parentf869b56fe4be416d356fffc94b8b18fe65039929 (diff)
downloadcpython-0fbb9afbddb93408e34bdb7625002374cb2ad68c.zip
cpython-0fbb9afbddb93408e34bdb7625002374cb2ad68c.tar.gz
cpython-0fbb9afbddb93408e34bdb7625002374cb2ad68c.tar.bz2
bpo-13886: Skip PTY non-ASCII tests if readline is loaded (GH-30631) (GH-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 ad6e640f910787e73fd00f59117fbd22cdf88c78) Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Victor Stinner <vstinner@python.org>
-rw-r--r--Lib/test/test_builtin.py16
-rw-r--r--Misc/NEWS.d/next/Tests/2022-01-17-13-10-04.bpo-13886.5mZH4b.rst3
2 files changed, 17 insertions, 2 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
index d009f57..1f224bf 100644
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -1980,12 +1980,24 @@ class PtyTests(unittest.TestCase):
# is different and invokes GNU readline if available).
self.check_input_tty("prompt", b"quux")
+ def skip_if_readline(self):
+ # bpo-13886: 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. Skip tests on non-ASCII characters if the
+ # readline module is loaded, since test_builtin is not intented to test
+ # the readline module, but the builtins module.
+ if 'readline' in sys.modules:
+ self.skipTest("the readline module is loaded")
+
def test_input_tty_non_ascii(self):
- # Check stdin/stdout encoding is used when invoking GNU readline
+ self.skip_if_readline()
+ # Check stdin/stdout encoding is used when invoking PyOS_Readline()
self.check_input_tty("prompté", b"quux\xe9", "utf-8")
def test_input_tty_non_ascii_unicode_errors(self):
- # Check stdin/stdout error handler is used when invoking GNU readline
+ self.skip_if_readline()
+ # Check stdin/stdout error handler is used when invoking PyOS_Readline()
self.check_input_tty("prompté", b"quux\xe9", "ascii")
def test_input_no_stdout_fileno(self):
diff --git a/Misc/NEWS.d/next/Tests/2022-01-17-13-10-04.bpo-13886.5mZH4b.rst b/Misc/NEWS.d/next/Tests/2022-01-17-13-10-04.bpo-13886.5mZH4b.rst
new file mode 100644
index 0000000..cd19dce
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2022-01-17-13-10-04.bpo-13886.5mZH4b.rst
@@ -0,0 +1,3 @@
+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. Patch by Victor Stinner.