Message150456
What I would do:
- build the namedtuple in Python rather than in C
- I don't particularly like CamelCased names for nametuples (I would use "size" instead of "TerminalSize")
- on UNIX, the ioctl() stuff can be done in python rather than in C
- use C only on Windows to deal with GetStdHandle/GetConsoleScreenBufferInfo; function name should be accessed as nt._get_terminal_size similarly to what we did for shutil.disk_usage in issue12442.
- do not raise NotImplementedError; if the required underlying functions are not available os.get_terminal_size should not exists in the first place (same as we did for shutil.disk_usage / issue12442)
Also, I'm not sure I like fallback=(80, 25) as default, followed by:
try:
size = query_terminal_size(sys.__stdout__.fileno())
except OSError:
size = TerminalSize(fallback)
That means we're never going to get an exception.
Instead I would:
- provide fallback as None
- let OSError propate unless fallback is not None |
|
Date |
User |
Action |
Args |
2012-01-02 13:55:34 | giampaolo.rodola | set | recipients:
+ giampaolo.rodola, loewis, amaury.forgeotdarc, pitrou, Arfrever, zbysz, denilsonsa, neologix, rosslagerwall |
2012-01-02 13:55:34 | giampaolo.rodola | set | messageid: <1325512534.29.0.621067522119.issue13609@psf.upfronthosting.co.za> |
2012-01-02 13:55:33 | giampaolo.rodola | link | issue13609 messages |
2012-01-02 13:55:32 | giampaolo.rodola | create | |
|