summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSoumendra Ganguly <67527439+8vasu@users.noreply.github.com>2020-11-27 10:16:41 (GMT)
committerGitHub <noreply@github.com>2020-11-27 10:16:41 (GMT)
commitf5a19ead4ba8c81cc27d5a530f830f4709ce240e (patch)
tree1207a47c33c9dd479f8adc0439d501ddca550e07
parentc8aaf71dde4888864c0c351e2f935f87652c3d54 (diff)
downloadcpython-f5a19ead4ba8c81cc27d5a530f830f4709ce240e.zip
cpython-f5a19ead4ba8c81cc27d5a530f830f4709ce240e.tar.gz
cpython-f5a19ead4ba8c81cc27d5a530f830f4709ce240e.tar.bz2
bpo-41818: Make test_openpty() avoid unexpected success due to number of rows and/or number of columns being == 0. (GH-23526)
-rw-r--r--Lib/test/test_pty.py29
-rw-r--r--Misc/NEWS.d/next/Library/2020-11-27-09-19-43.bpo-41818.KWYUbL.rst1
2 files changed, 11 insertions, 19 deletions
diff --git a/Lib/test/test_pty.py b/Lib/test/test_pty.py
index 138560e..a45be28 100644
--- a/Lib/test/test_pty.py
+++ b/Lib/test/test_pty.py
@@ -5,7 +5,6 @@ from test.support.import_helper import import_module
import_module('termios')
import errno
-import pathlib
import pty
import os
import sys
@@ -75,20 +74,7 @@ def _readline(fd):
return reader.readline()
def expectedFailureIfStdinIsTTY(fun):
- # avoid isatty() for now
- PLATFORM = platform.system()
- if PLATFORM == "Linux":
- os_release = pathlib.Path("/etc/os-release")
- if os_release.exists():
- # Actually the file has complex multi-line structure,
- # these is no need to parse it for Gentoo check
- if 'gentoo' in os_release.read_text().lower():
- # bpo-41818:
- # Gentoo passes the test,
- # all other tested Linux distributions fail.
- # Should not apply @unittest.expectedFailure() on Gentoo
- # to keep the buildbot fleet happy.
- return fun
+ # avoid isatty()
try:
tty.tcgetattr(pty.STDIN_FILENO)
return unittest.expectedFailure(fun)
@@ -165,11 +151,16 @@ class PtyTest(unittest.TestCase):
new_stdin_winsz = None
if self.stdin_rows != None and self.stdin_cols != None:
try:
+ # Modify pty.STDIN_FILENO window size; we need to
+ # check if pty.openpty() is able to set pty slave
+ # window size accordingly.
debug("Setting pty.STDIN_FILENO window size")
- # Set number of columns and rows to be the
- # floors of 1/5 of respective original values
- target_stdin_winsz = struct.pack("HHHH", self.stdin_rows//5,
- self.stdin_cols//5, 0, 0)
+ debug(f"original size: (rows={self.stdin_rows}, cols={self.stdin_cols})")
+ target_stdin_rows = self.stdin_rows + 1
+ target_stdin_cols = self.stdin_cols + 1
+ debug(f"target size: (rows={target_stdin_rows}, cols={target_stdin_cols})")
+ target_stdin_winsz = struct.pack("HHHH", target_stdin_rows,
+ target_stdin_cols, 0, 0)
_set_term_winsz(pty.STDIN_FILENO, target_stdin_winsz)
# Were we able to set the window size
diff --git a/Misc/NEWS.d/next/Library/2020-11-27-09-19-43.bpo-41818.KWYUbL.rst b/Misc/NEWS.d/next/Library/2020-11-27-09-19-43.bpo-41818.KWYUbL.rst
new file mode 100644
index 0000000..56cdc9a
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-11-27-09-19-43.bpo-41818.KWYUbL.rst
@@ -0,0 +1 @@
+Make test_openpty() avoid unexpected success due to number of rows and/or number of columns being == 0. \ No newline at end of file