Message246053
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. |
|
Date |
User |
Action |
Args |
2015-07-02 01:57:02 | eryksun | set | recipients:
+ eryksun, vstinner, tim.golden, Drekin |
2015-07-02 01:57:02 | eryksun | set | messageid: <1435802222.07.0.985749845586.issue18597@psf.upfronthosting.co.za> |
2015-07-02 01:57:01 | eryksun | link | issue18597 messages |
2015-07-02 01:57:00 | eryksun | create | |
|