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, paul.moore, steve.dower, tim.golden, valer, zach.ware
Date 2018-07-20.12:44:22
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1532090662.87.0.56676864532.issue28166@psf.upfronthosting.co.za>
In-reply-to
Content
> all the input before the ignored Ctrl+C is lost

The console host process doesn't know that Python is ignoring Ctrl+C, so it cancels the read and flushes the input buffer. For now, we have to accept this as a limitation of relying on the high-level console API (i.e. ReadConsoleW with the default settings), which implements command-line editing, aliases and history completely in the console host process. Restarting the read with a flushed input buffer is better than raising EOFError or exiting the REPL.

In the future, Python's console readline implementation could hook deeper into the operation by temporarily disabling the console's ENABLE_PROCESSED_INPUT mode and using the pInputControl parameter to handle ^C and ^H (backspace). This would be fairly involved but still an imperfect solution because ^C will replace whichever character is under the cursor (fine if the cursor is at the end of the line, but otherwise pretty clunky). The only way to have complete control is to use the low-level ReadConsoleInput function. pyreadline implements this via ctypes.
History
Date User Action Args
2018-07-20 12:44:22eryksunsetrecipients: + eryksun, paul.moore, tim.golden, zach.ware, steve.dower, valer
2018-07-20 12:44:22eryksunsetmessageid: <1532090662.87.0.56676864532.issue28166@psf.upfronthosting.co.za>
2018-07-20 12:44:22eryksunlinkissue28166 messages
2018-07-20 12:44:22eryksuncreate