gh-133537: Avoid using console I/O in WinAPI partitions that don't support it (GH-133538)

This commit is contained in:
Max Bachmann 2025-05-07 21:47:05 +02:00 committed by GitHub
parent 427f8c366d
commit 1460ccefd0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 0 deletions

View file

@ -0,0 +1 @@
Avoid using console I/O in WinAPI partitions that dont support it

View file

@ -16875,12 +16875,16 @@ static PyObject *
os__supports_virtual_terminal_impl(PyObject *module)
/*[clinic end generated code: output=bd0556a6d9d99fe6 input=0752c98e5d321542]*/
{
#ifdef HAVE_WINDOWS_CONSOLE_IO
DWORD mode = 0;
HANDLE handle = GetStdHandle(STD_ERROR_HANDLE);
if (!GetConsoleMode(handle, &mode)) {
Py_RETURN_FALSE;
}
return PyBool_FromLong(mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING);
#else
Py_RETURN_FALSE;
#endif /* HAVE_WINDOWS_CONSOLE_IO */
}
#endif