eryksun added the comment:

In Windows 10 ReadFile doesn't set ERROR_OPERATION_ABORTED (995) for Ctrl+C 
when reading console input, but ReadConsole does. 

    >>> from ctypes import *
    >>> kernel32 = WinDLL('kernel32', use_last_error=True)
    >>> buf = (c_char * 1)()
    >>> n = c_uint()
    >>> kernel32.ReadFile(kernel32.GetStdHandle(-10), buf, 1, byref(n), None)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    KeyboardInterrupt
    >>> get_last_error()
    0
    >>> kernel32.ReadConsoleA(kernel32.GetStdHandle(-10), buf, 1, byref(n), 
None)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    KeyboardInterrupt
    >>> get_last_error()
    995

Add this to the list of reasons Python should be using the console API for 
interactive standard streams. As is Ctrl+C is killing the REPL since it gets 
interpreted as EOF. This bug probably applies to Windows 8, too. Could someone 
check?

Background:
In Windows 7 reading from the console is implemented with a common code path to 
make an LPC call (NtRequestWaitReplyPort) to the console host process, 
conhost.exe. This was all completely redesigned for Windows 8, which instead 
uses the ConDrv device driver. Now ReadFile calls NtReadFile, and ReadConsole 
calls NtDeviceIoControlFile. When splitting this up they apparently forgot to 
set ERROR_OPERATION_ABORTED for Ctrl+C in ReadFile.

----------
nosy: +eryksun
versions: +Python 3.4, Python 3.5, Python 3.6

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

Reply via email to