diff options
author | Raghunandan Bhat <33787364+raghunandanbhat@users.noreply.github.com> | 2022-07-28 22:48:33 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-28 22:48:33 (GMT) |
commit | edb72047f35d6da48c59bcfe0c655939a88ea0a6 (patch) | |
tree | c1967d93c141766ad00407ba995ff35903733e67 /Modules/posixmodule.c | |
parent | 390847922c8f93db6f639d6e0ab3e53aefa60c76 (diff) | |
download | cpython-edb72047f35d6da48c59bcfe0c655939a88ea0a6.zip cpython-edb72047f35d6da48c59bcfe0c655939a88ea0a6.tar.gz cpython-edb72047f35d6da48c59bcfe0c655939a88ea0a6.tar.bz2 |
gh-43414: os.get_terminal_size() now uses the actual file descriptor on Windows instead of mapping to standard handles (#93203)
Diffstat (limited to 'Modules/posixmodule.c')
-rw-r--r-- | Modules/posixmodule.c | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 5855c42..d45fa23 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -13247,24 +13247,11 @@ os_get_terminal_size_impl(PyObject *module, int fd) #ifdef TERMSIZE_USE_CONIO { - DWORD nhandle; HANDLE handle; CONSOLE_SCREEN_BUFFER_INFO csbi; - switch (fd) { - case 0: nhandle = STD_INPUT_HANDLE; - break; - case 1: nhandle = STD_OUTPUT_HANDLE; - break; - case 2: nhandle = STD_ERROR_HANDLE; - break; - default: - return PyErr_Format(PyExc_ValueError, "bad file descriptor"); - } - handle = GetStdHandle(nhandle); - if (handle == NULL) - return PyErr_Format(PyExc_OSError, "handle cannot be retrieved"); + handle = _Py_get_osfhandle(fd); if (handle == INVALID_HANDLE_VALUE) - return PyErr_SetFromWindowsErr(0); + return NULL; if (!GetConsoleScreenBufferInfo(handle, &csbi)) return PyErr_SetFromWindowsErr(0); |