Martin Panter added the comment:

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'

----------
keywords: +patch
nosy: +martin.panter
Added file: http://bugs.python.org/file46771/int-unix.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29926>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to