Zbyszek Szmek <zbys...@in.waw.pl> added the comment:

Following comments by Martin and Victor, here is next version: termsize.diff.4

Changes:
- just check for defined(MS_WINDOWS) and rely on <windows.h>.
- rename query_terminal_size to get_terminal_size_raw
     This way it should be clearer that the second one is low-level,
     and should be less exposed. I don't want to call it
     _get_terminal_size() because it is not just an implementation
     detail and would sometimes be called directly.
- NotImplementedError is gone. get_terminal_size_raw() is not
  defined if not possible.

Non-changes:
- sys.__stdout__.fileno() is not changed to 1, because as Antoine
  pointed out, it is set at runtime.
- STDOUT_FILENO: not defined on windows, so just use 1 and add a comment
- fd argument is retained, because we might want to test terminals
  opened with openpty.
- two functions: still there. I think that get_terminal_size() should
  provide an easy-to-use, even trivial-to-use, way to get a sensible
  value without writing a wrapper. In the _majority_ of cases the
  wrapper would be something like get_terminal_size() currently.
- named tuple: like Antoine said, it gives nice syntax.
- testing for <sys/ioctl.h>: in termios and other modules, setup.py
  first tests if we are on unix. But there might be unices without
  TIOCGWINSZ, and non-unix systems where TIOCGWINSZ _is_ defined,
  so it seems a functional test is simpler and more robust.

Tested on linux and windows XP.

----------
Added file: http://bugs.python.org/file24150/termsize.diff.4

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue13609>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to