Eryk Sun added the comment:

Windows doesn't have terminal devices, so the C runtime's isatty() function 
just checks for a character device, which includes NUL among others. 

This can lead to hanging the REPL, albeit with a contrived example such as 
redirecting stdin to COM3:

    C:\>python < COM3
    Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) 
    [MSC v.1900 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> ^C

Ctrl+C doesn't work because the main thread is blocked (we'd have to call 
CancelSynchronousIo in the C signal handler). I killed the process using the 
default Ctrl+Break handler. "^C" was printed by the cmd shell's Ctrl+Break 
handler.

I don't think the CRT's check for a character device is generally useful. It 
could be replaced with a check that specifically looks for a console handle 
(e.g. by calling GetConsoleMode), which is what someone calling isatty() 
generally wants to know.

----------
components: +IO
nosy: +eryksun
versions: +Python 3.6, Python 3.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28654>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to