Author haypo
Recipients benjamin.peterson, gjb1002, haypo
Date 2010-03-08.00:36:29
SpamBayes Score 4.12503e-13
Marked as misclassified No
Message-id <>
Using "valgrind --log-file=/tmp/trace ./python" to slow down Python, I found another bug in the interactive interpreter: if you press CTRL+c just after the initialization of the site module the exception will be ignored.

When a signal is catched, it's stored in a table, and the real handler is called later (by Py_MakePendingCalls()). Py_AddPendingCall() is called to ensure that the signal will be handled before the next Python instruction. In my case, the next Python instruction is "decode the string written by the user using the terminal encoding" called by the tokenizer... but the tokenizer ignores all errors (not only unicode errors): see tok_stdin_decode().

Recipe to catch the code responsible to ignore the keyboard interrupt exception (using gdb):
$ gdb ./python
(gdb) b initsite
Breakpoint 1, initsite ()
(gdb) run
Breakpoint 1, initsite ()
(gdb) next
<execution of the site module>
(gdb) b signal_default_int_handler
Breakpoint 2
(gdb) signal SIGINT
Breakpoint 2, signal_default_int_handler
(gdb) b PyErr_Clear
Breakpoint 3
(gdb) cont
Breakpoint 3, PyErr_Clear ()
(gdb) where

Attached patch calls Py_MakePendingCalls() before PyRun_AnyFileExFlags() to avoid the tokenizer bug. It's just a workaround, not a real bugfix.
Date User Action Args
2010-03-08 00:36:31hayposetrecipients: + haypo, gjb1002, benjamin.peterson
2010-03-08 00:36:31hayposetmessageid: <>
2010-03-08 00:36:30haypolinkissue3137 messages
2010-03-08 00:36:29haypocreate