classification
Title: asyncio REPL swallows KeyboardInterrupt while editing
Type: Stage:
Components: asyncio Versions: Python 3.9, Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: asvetlov, iomintz, yselivanov
Priority: normal Keywords:

Created on 2019-12-03 00:10 by iomintz, last changed 2019-12-03 00:10 by iomintz.

Messages (1)
msg357738 - (view) Author: Io Mintz (iomintz) * Date: 2019-12-03 00:10
"python3 -m asyncio" swallows KeyboardInterrupt while editing a line.

Problem steps:
==============

- run python -m asyncio
- press ^C

Expected behavior (normal CPython REPL, as well as python -m code):
==================================================================

The current input line is abandoned and "\nKeyboardInterrupt" is printed.

Sample for "spam^C" with the normal REPL:
-----------------------------------------

Python 3.8.0 (default, Oct 23 2019, 18:51:26) 
[GCC 9.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> spam
KeyboardInterrupt

Python 3.9.0a1+ (heads/master:a62ad4730c, Dec  2 2019, 17:38:37) 
[GCC 9.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> spam
KeyboardInterrupt


Sample for "spam^C" in the InteractiveConsole REPL, as invoked by `python -m code`:
-----------------------------------------------------------------------------------

Python 3.8.0 (default, Oct 23 2019, 18:51:26) 
[GCC 9.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> spam
KeyboardInterrupt

Python 3.9.0a1+ (heads/master:a62ad4730c, Dec  2 2019, 17:38:37) 
[GCC 9.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> spam
KeyboardInterrupt


Actual behavior:
================

The KeyboardInterrupt is ignored, the current input line remains on screen, and a new line is not started:

asyncio REPL 3.8.0 (default, Oct 23 2019, 18:51:26) 
[GCC 9.2.0] on linux
Use "await" directly instead of "asyncio.run()".
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncio
>>> spam

asyncio REPL 3.9.0a1+ (heads/master:a62ad4730c, Dec  2 2019, 17:38:37) 
[GCC 9.2.0] on linux
Use "await" directly instead of "asyncio.run()".
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncio
>>> spam


Workaround
==========

If editing a continued block (ie a line prefixed by sys.ps2 / "..."), enter any invalid syntax (such as unindented code) to cancel the current block. If editing a single line, press ^U to clear the line.

OS Details
==========

Arch Linux, python extra/python 3.8.0-1.
History
Date User Action Args
2019-12-03 00:10:02iomintzcreate