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 martin.panter
Recipients Mark, eryksun, martin.panter, njs, terry.reedy
Date 2017-04-03.03:37:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1491190632.79.0.531121803883.issue29926@psf.upfronthosting.co.za>
In-reply-to
Content
Hi Terry, this patch is what I imagined a fix would look like for Linux. I am not familiar with Idle (internally nor externally), so there may be improvements you can make.

It works as I expected for normal blocking functions and a tight “for” loop: it interrupts any blocking call, and triggers the usual SIGINT handler. If SIGINT has a Python handler (e.g. by default), that gets called which usually raises KeyboardInterrupt.

My change has a major flaw: it seems to deadlock something if you interrupt “input()” or “sys.stdin.readline()”. Perhaps you might have a better clue what the problem is. With the default SIGINT handler, this is what I see in the Idle window:

>>> input()  # Press Ctrl+C
Traceback (most recent call last):  <-- cursor flashing at end of line

If SIGINT is ignored, or the Python handler doesn’t raise an exception, Ctrl+C seems to have the effect of inputting a newline:

>>> input()  # Press Ctrl+C
''
>>> sys.stdin.readline()  # Press Ctrl+C
'\n'
History
Date User Action Args
2017-04-03 03:37:12martin.pantersetrecipients: + martin.panter, terry.reedy, njs, Mark, eryksun
2017-04-03 03:37:12martin.pantersetmessageid: <1491190632.79.0.531121803883.issue29926@psf.upfronthosting.co.za>
2017-04-03 03:37:12martin.panterlinkissue29926 messages
2017-04-03 03:37:11martin.pantercreate