KeyboardInterrupt in a select menu should clear options
EliseAv opened this issue · comments
Code to reproduce:
try:
survey.select("Argentina France Croacia Morocco".split())
except KeyboardInterrupt:
pass
Run the above script and press Ctrl+C to interrupt the script and return to console (e.g. bash).
Actual result:
Console prompt is in the middle of the displayed options.
Expected result:
Either it returns after the options or it erases the options.
This is the intended behavior, as KeyboardInterrupt
is not handled in any special way. The script simply stops execution and begins showing the traceback from the current cursor position, which is likely among the options provided at that time.
This is in line with using the built-in input
function and placing the cursor among text before Ctrl+C'ing.
I'm sorry I didn't communicate clearly. I agree that KeyboardInterrupt should interrupt and print the stack trace. However, when I'm displaying 24 very wordy options and the stack trace is only 3 levels deep, it gets very unwieldy.
What I'm saying is that yes this specific exception should be handled in the following way:
- clear the options below the cursor (indifferent if the options above the cursor get cleared too)
- re-raise the exception so the caller code can choose to either catch it or die
I understand. This is fixed in release 4.