[issue13609] Add "os.get_terminal_size()" function

Zbyszek Szmek report at bugs.python.org
Mon Feb 13 00:28:22 CET 2012


Zbyszek Szmek <zbyszek at in.waw.pl> added the comment:

> Using strace, I see that stty calls ioctl(TIOCGWINSZ) on stdin (fd=0)
> if it failed on stdout (fd=1), whereas Python only tries stdout.
It was done this way by design. Maybe checking stdin can be also useful,
but it is a rather big change in semantics. I think it should be a separate bug.

It is pretty common for programs to behave differently when run through pipe, even if stdin is on a tty. stty is rather the exception than the rule. E.g. almost all programs disable color when piped explicitly through less. 'dpkg | cat' ignores terminal width. So does git and ls.
stty is special, because the only purpose of that program is to query terminal size, but it cannot be taken as a model for the behaviour of a general purpose program.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13609>
_______________________________________


More information about the Python-bugs-list mailing list