Message388187
Currently os.get_terminal_size() is hard coded to use the process standard handles in Windows. The function, however, is intended for arbitrary file descriptors, so should not be limited as follows:
>>> f = open('conout$', 'w')
>>> os.get_terminal_size(f.fileno())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: bad file descriptor
This is a simple fix. Rewrite it to use _get_osfhandle(). For example:
#ifdef TERMSIZE_USE_CONIO
{
HANDLE handle;
CONSOLE_SCREEN_BUFFER_INFO csbi;
_Py_BEGIN_SUPPRESS_IPH
handle = (HANDLE)_get_osfhandle(fd);
_Py_END_SUPPRESS_IPH
if (handle == INVALID_HANDLE_VALUE)
return PyErr_SetFromErrno(PyExc_OSError);
if (!GetConsoleScreenBufferInfo(handle, &csbi))
return PyErr_SetFromWindowsErr(0);
columns = csbi.srWindow.Right - csbi.srWindow.Left + 1;
lines = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
}
#endif /* TERMSIZE_USE_CONIO */ |
|
Date |
User |
Action |
Args |
2021-03-06 01:58:09 | eryksun | set | recipients:
+ eryksun, paul.moore, tim.golden, zach.ware, steve.dower |
2021-03-06 01:58:09 | eryksun | set | messageid: <1614995889.38.0.729191122852.issue43414@roundup.psfhosted.org> |
2021-03-06 01:58:09 | eryksun | link | issue43414 messages |
2021-03-06 01:58:09 | eryksun | create | |
|