summaryrefslogtreecommitdiff
path: root/Lib/pdb.py
diff options
context:
space:
mode:
authorXavier de Gaye <xdegaye@users.sourceforge.net>2016-10-12 20:16:05 +0200
committerXavier de Gaye <xdegaye@users.sourceforge.net>2016-10-12 20:16:05 +0200
commit291417da7fc141e4ede93b804b6532460f2cc528 (patch)
treef3a549756e13db2ec60b6bf9bcecd85ea2fa202e /Lib/pdb.py
parentebe17e0347944b01a771eae4cee7f2a38cc82e42 (diff)
parent10e54aeaa234f2806b367c66e3fb4ac6568b39f6 (diff)
downloadcpython-git-291417da7fc141e4ede93b804b6532460f2cc528.tar.gz
Issue #20766: Merge with 3.5.
Diffstat (limited to 'Lib/pdb.py')
-rwxr-xr-xLib/pdb.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/Lib/pdb.py b/Lib/pdb.py
index 7eb78b922a..97618b0ff1 100755
--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -135,6 +135,8 @@ line_prefix = '\n-> ' # Probably a better default
class Pdb(bdb.Bdb, cmd.Cmd):
+ _previous_sigint_handler = None
+
def __init__(self, completekey='tab', stdin=None, stdout=None, skip=None,
nosigint=False, readrc=True):
bdb.Bdb.__init__(self, skip=skip)
@@ -189,8 +191,6 @@ class Pdb(bdb.Bdb, cmd.Cmd):
self.message("\nProgram interrupted. (Use 'cont' to resume).")
self.set_step()
self.set_trace(frame)
- # restore previous signal handler
- signal.signal(signal.SIGINT, self._previous_sigint_handler)
def reset(self):
bdb.Bdb.reset(self)
@@ -339,6 +339,10 @@ class Pdb(bdb.Bdb, cmd.Cmd):
(expr, newvalue, oldvalue))
def interaction(self, frame, traceback):
+ # Restore the previous signal handler at the Pdb prompt.
+ if Pdb._previous_sigint_handler:
+ signal.signal(signal.SIGINT, Pdb._previous_sigint_handler)
+ Pdb._previous_sigint_handler = None
if self.setup(frame, traceback):
# no interaction desired at this time (happens if .pdbrc contains
# a command like "continue")
@@ -1039,7 +1043,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
"""
if not self.nosigint:
try:
- self._previous_sigint_handler = \
+ Pdb._previous_sigint_handler = \
signal.signal(signal.SIGINT, self.sigint_handler)
except ValueError:
# ValueError happens when do_continue() is invoked from