Author eryksun
Recipients Drekin, eryksun, tim.golden, vstinner
Date 2015-07-02.01:57:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1435802222.07.0.985749845586.issue18597@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2015-07-02 01:57:02eryksunsetrecipients: + eryksun, vstinner, tim.golden, Drekin
2015-07-02 01:57:02eryksunsetmessageid: <1435802222.07.0.985749845586.issue18597@psf.upfronthosting.co.za>
2015-07-02 01:57:01eryksunlinkissue18597 messages
2015-07-02 01:57:00eryksuncreate