Break impasse between Python and Illumos pty code - just set the window size if we can't get it. Reported to cpython as https://github.com/python/cpython/issues/115189 --- Python-3.12.1/Modules/termios.c.~1~ Thu Dec 7 12:45:44 2023 +++ Python-3.12.1/Modules/termios.c Wed Feb 7 12:12:09 2024 @@ -483,9 +483,12 @@ #if defined(TIOCGWINSZ) && defined(TIOCSWINSZ) struct winsize w; /* Get the old winsize because it might have - more fields such as xpixel, ypixel. */ + more fields such as xpixel, ypixel, but keep going and + try to set it even if this fails since on some systems + on a new pty you can't get the winsize until it's been + set once. */ if (ioctl(fd, TIOCGWINSZ, &w) == -1) { - return PyErr_SetFromErrno(state->TermiosError); + memset(&w, 0, sizeof(w)); } w.ws_row = (unsigned short) winsz_0; --- Python-3.12.1/Lib/test/test_termios.py.~1~ Thu Dec 7 12:45:44 2023 +++ Python-3.12.1/Lib/test/test_termios.py Wed Feb 7 12:35:49 2024 @@ -13,6 +13,16 @@ def setUp(self): master_fd, self.fd = os.openpty() + # some systems will not let you get the window size unless it's been + # set first, so try to set it if we can't get it + try: + termios.tcgetwinsize(self.fd) + except termios.error: + try: + termios.tcsetwinsize(self.fd, (24, 80)) + except termios.error: + pass + self.addCleanup(os.close, master_fd) self.stream = self.enterContext(open(self.fd, 'wb', buffering=0)) tmp = self.enterContext(tempfile.TemporaryFile(mode='wb', buffering=0))