Zbyszek Szmek <zbys...@in.waw.pl> added the comment: > Some remarks on the Windows implementation in termsize.diff.4:
> - On Windows, the C runtime always sets fileno(stdout) to 1, so > hardcoded values are OK. > But on Unix, I'm quite sure that embedded interpreters (mod_python?) > sometimes close the standard descriptor, so fd=1 can refer to > something entirely different. > Does it makes sense to initialize fd=fileno(stdout) (this is C code) > instead? OK, I agree that fd=fileno(stdout) is better. Now it matches the docstring which says "defaults to stdout" better. > - When GetStdHandle() returns INVALID_HANDLE_VALUE, > PyErr_SetFromWindowsErr(0) should be used. OK. > And it's not necessary to use GetLastError(), 0 is enough. OK, good no know. > - GetStdHandle will return NULL in a non-console application (try > with pythonw.exe or IDLE), I think a specific error message should be > raised in this case. OK. I tried and I see that the GetStdHandle documentation says so, but I couldn't get it to return NULL. Nevertheless, I added a check: + if (handle == NULL) + return PyErr_Format(PyExc_OSError, "stdout not connected"); Thanks for the review! Updated: termsize.diff.5 ---------- Added file: http://bugs.python.org/file24157/termsize.diff.5 _______________________________________ 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