Author zbysz
Recipients Arfrever, amaury.forgeotdarc, denilsonsa, eric.araujo, giampaolo.rodola, loewis, neologix, pitrou, python-dev, rosslagerwall, techtonik, vstinner, zbysz
Date 2012-02-15.00:17:40
SpamBayes Score 1.61633e-11
Marked as misclassified No
Message-id <1329265061.63.0.0339432166365.issue13609@psf.upfronthosting.co.za>
In-reply-to
Content
> New try (I fixed my email address and the patch).
>
> The purpose of os.get_terminal_size() is the same as `stty size`, so 
> `stty size` could be a model for behavior of os.get_terminal_size().
I guess that this fallback will make some things easier. As long it is documented, the user should be able to get whatever behaviour they want.

I have four small questions:
- -1 is used as the argument meaning "try stdout and stdin". But -1 is 
  also used the error return value for open(2) and other system 
  functions. I know that Python checks the return value to throw an 
  exception, and -1 shouldn't "leak" and be passed by mistake to 
  os.get_terminal_size(). Can someone confirm that this is
  the case?
- Why stderr is not checked too? It would make os.get_terminal_size()
  return the real terminal value in a the middle of a pipe:
    cat | python -c 'import os; os.get_terminal_size()' | cat.
- some doc change is missing
- in the new version the line with ioctl(fd, TIOCGWINSZ, &w) repeats
  three times. It think it could be reduced to two without loss
  of readability.
History
Date User Action Args
2012-02-15 00:17:41zbyszsetrecipients: + zbysz, loewis, amaury.forgeotdarc, pitrou, vstinner, techtonik, giampaolo.rodola, eric.araujo, Arfrever, denilsonsa, neologix, rosslagerwall, python-dev
2012-02-15 00:17:41zbyszsetmessageid: <1329265061.63.0.0339432166365.issue13609@psf.upfronthosting.co.za>
2012-02-15 00:17:41zbyszlinkissue13609 messages
2012-02-15 00:17:40zbyszcreate