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.

classification
Title: Inconsistent behavior in pdb when pressing Ctrl-C
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, steven.downum, xdegaye
Priority: normal Keywords: patch

Created on 2014-01-15 09:28 by xdegaye, last changed 2022-04-11 14:57 by admin.

Files
File name Uploaded Description Edit
sigint.patch xdegaye, 2014-01-15 09:28 review
sigint_2.patch xdegaye, 2014-05-24 13:33 review
Messages (2)
msg208151 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2014-01-15 09:28
With this script:
# START
def foo():
    while 1:
        pass

import pdb; pdb.set_trace()
foo()
# END

The following sequence of pdb commands aborts the script with a KeyboardInterrupt exception:
  next
  Ctrl-C
  continue

While the equivalent following sequence of commands allows the debugging session to continue as
expected:
  continue
  Ctrl-C
  continue

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.
msg219040 - (view) Author: Xavier de Gaye (xdegaye) * (Python triager) Date: 2014-05-24 13:33
The patch with a test case.
History
Date User Action Args
2022-04-11 14:57:57adminsetgithub: 64468
2014-05-24 13:33:50xdegayesetfiles: + sigint_2.patch

messages: + msg219040
2014-02-19 20:42:57steven.downumsetnosy: + steven.downum
2014-01-15 09:28:52xdegayecreate