STINNER Victor <victor.stin...@haypocalc.com> added the comment: 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. ---------- Added file: http://bugs.python.org/file16489/main_pending_calls.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue3137> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com