Message100619
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
<HERE YOU HAVE>
---------------------
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:31 | vstinner | set | recipients:
+ vstinner, gjb1002, benjamin.peterson |
2010-03-08 00:36:31 | vstinner | set | messageid: <1268008591.83.0.861771803844.issue3137@psf.upfronthosting.co.za> |
2010-03-08 00:36:30 | vstinner | link | issue3137 messages |
2010-03-08 00:36:29 | vstinner | create | |
|