bpo-30555: Fix WindowsConsoleIO errors in the presence of fd redirection by segevfiner · Pull Request #1927 · python/cpython

eryksun

…tion

This works by not caching the handle and instead getting the handle from
the file descriptor each time, so that if the actual handle changes by
fd redirection closing/opening the console handle beneath our feet, we
will keep working correctly.

I think I also fixed some resource handling issues along the way since
ucrt/msvcrt fds *own* the HANDLEs they use and this module tried to
close them itself.

@segevfiner

The change in test_winconsoleio.py is only to avoid the ref leak in
`sys.getwindowsversion`.

@segevfiner

@segevfiner

eryksun

@segevfiner

eryksun

@segevfiner

…consoleio-fd-redirection

@segevfiner

…consoleio-fd-redirection

@segevfiner

…consoleio-fd-redirection
…consoleio-fd-redirection
…consoleio-fd-redirection

@segevfiner

@segevfiner

…consoleio-fd-redirection
Co-authored-by: Eryk Sun <eryksun@gmail.com>

@segevfiner

@segevfiner segevfiner deleted the bpo-30555-windowsconsoleio-fd-redirection branch

February 21, 2022 09:38

This was referenced

Jan 5, 2024