-
-
Notifications
You must be signed in to change notification settings - Fork 33.4k
Description
Bug report
Bug description:
While working on packaging Python 3.12 for OpenIndiana I noticed failures in Lib/test/test_termios.py, which boil down to a comical "you go first" / "no, I insist, you go first" standoff between Modules/termios.c and the illumos kernel's pty code.
illumos will not return success from TIOCGWINSZ unless a prior TIOCSWINSZ has set at least one of the four dimensions to a non-zero value, while a freshly created pty has all four set to zero. See https://github.com/illumos/illumos-gate/blame/0c4d3ec56b3e8f2f8bcc4dbe1eb32871e2663b39/usr/src/uts/common/io/ptem.c#L936-L943
Meanwhile, Python refuses to call TIOCSWINSZ to set the window size unless a prior call to TIOCGWINSZ succeeds, lest it clobber the rarely-used ws_xpixel and ws_ypixel fields.
As a result, all of the termios window size tests fail even though the interface is fully functional on a pty that someone else initialized with a window size.
In my draft patch for this at Bill-Sommerfeld/oi-userland@fd47054
I have Python break the impasse - if TIOCGWINSZ fails in termios_tcgetwinsize_impl, just zero out our struct winsize w and drive on to try to set the size with the caller-provided rows and columns values.
The patch also fixes the test to set a non-zero window size on the pty allocated by the test if termios.tcgetwinsize fails in the setup code.
I'll be happy to convert this patch to a pull request on some branch of the python repo if that would be appropriate.
CPython versions tested on:
3.12
Operating systems tested on:
Other