[Python-Dev] KeyboardInterrupt not catch

Ben Finney ben+python at benfinney.id.au
Mon Nov 8 05:05:05 CET 2010


Qi Yong <qiyong at sosdg.org> writes:

> With this script, after ctrl-d, ctrl-c exception not catch.

When I run it, the Ctrl-D doesn't affect the behaviour of Ctrl-C. Can
you confirm that the behaviour is dependent on whether Ctrl-D is used?

> If with import readline, this problem disappears.

Again, if I ‘import readline’ or not, the behaviour is unchanged. Can
you show a specific series of steps that changes the behaviour?

> Is it a python bug or a wrong exception usage? Thanks.

The ‘raw_input’ function uses the ‘readline’ library. That library uses
signal handlers for many of the terminal signals, as documented at
<URL:http://cnswww.cns.cwru.edu/php/chet/readline/readline.html#SEC43>.

-- 
 \       “You've got the brain of a four-year-old boy, and I'll bet he |
  `\                         was glad to get rid of it.” —Groucho Marx |
_o__)                                                                  |
Ben Finney



More information about the Python-Dev mailing list