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 vstinner
Recipients benjamin.peterson, gjb1002, vstinner
Date 2010-03-08.00:36:29
SpamBayes Score 4.1250336e-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:31vstinnersetrecipients: + vstinner, gjb1002, benjamin.peterson
2010-03-08 00:36:31vstinnersetmessageid: <>
2010-03-08 00:36:30vstinnerlinkissue3137 messages
2010-03-08 00:36:29vstinnercreate