This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients eryksun, matejcik
Date 2021-07-28.15:52:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1627487579.75.0.15257382984.issue44762@roundup.psfhosted.org>
In-reply-to
Content
> When the check incorrectly infers that it can use `msvcrt` while 
> its stdin is a pipe, the calls to `putwch` and `getwch` are going 
> into the void and the program effectively freezes waiting for 
> input that never comes.

The C runtime's getwch() and putwch() functions use the console I/O files "CONIN$" and "CONOUT$". If "CONIN$" can't be opened because the process has no console, then getwch() fails and returns U+FFFF. But mintty does have a console, albeit with a hidden window, which gets inherited by bash and child processes. So getwch() ends up waiting for a key to be pressed in an inaccessible, hidden window.

It should suffice to check that sys.stdin isn't None and that sys.stdin.isatty() is True, since it's reasonable to assume that the console has a visible window in this case. Currently this isn't a bulletproof check, however, because the Windows C runtime doesn't implement isatty() correctly. It returns true for any character device, which includes the common case of redirecting standard I/O to the "NUL" device. io.FileIO.isatty() could be updated to return True only if both C isatty() is true and GetConsoleMode() succeeds. This would filter out false positives for non-console character devices, particularly "NUL".
History
Date User Action Args
2021-07-28 15:52:59eryksunsetrecipients: + eryksun, matejcik
2021-07-28 15:52:59eryksunsetmessageid: <1627487579.75.0.15257382984.issue44762@roundup.psfhosted.org>
2021-07-28 15:52:59eryksunlinkissue44762 messages
2021-07-28 15:52:59eryksuncreate