[New-bugs-announce] [issue20269] Inconsistent behavior in pdb when pressing Ctrl-C

Xavier de Gaye report at bugs.python.org
Wed Jan 15 10:28:52 CET 2014

New submission from Xavier de Gaye:

With this script:
def foo():
    while 1:

import pdb; pdb.set_trace()

The following sequence of pdb commands aborts the script with a KeyboardInterrupt exception:

While the equivalent following sequence of commands allows the debugging session to continue as

The first sequence of commands should behave as the second one.

A related problem is that the original SIGINT handler (named _previous_sigint_handler in the code)
is not restored when the program being debugged is stopped at a breakpoint that has been reached
after 'continue'.  _previous_sigint_handler is lost forever in this case when the user hits
'continue' after stopping at that breakpoint, which is quite common. This is annoying. For example,
trying to extend pdb with a 'detach' command that enables the debuggee to run freely after the
debugging session is terminated: the program cannot be killed anymore with SIGINT when the above
case occurs.

The attached patch attempts to fix these problems.
After applying the attached patch, the behavior of the 'next, Ctrl-C, continue' sequence of commands
is still wrong: this is another bug logged at issue 14788 with a patch and a test. Applying patch
14788 fixes this.

components: Library (Lib)
files: sigint.patch
keywords: patch
messages: 208151
nosy: georg.brandl, xdegaye
priority: normal
severity: normal
status: open
title: Inconsistent behavior in pdb when pressing Ctrl-C
type: behavior
versions: Python 3.5
Added file: http://bugs.python.org/file33478/sigint.patch

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list