summaryrefslogtreecommitdiffstats
path: root/Lib/pdb.py
diff options
context:
space:
mode:
authorTian Gao <gaogaotiantian@hotmail.com>2024-07-11 02:54:27 (GMT)
committerGitHub <noreply@github.com>2024-07-11 02:54:27 (GMT)
commit690b9355e00d1ea52020fde3feb4c043a2b214e2 (patch)
treee83456c4be7bfc1d33ba5fc2f92ea951cbf3e9ef /Lib/pdb.py
parent6557af669899f18f8d123f8e1b6c3380d502c519 (diff)
downloadcpython-690b9355e00d1ea52020fde3feb4c043a2b214e2.zip
cpython-690b9355e00d1ea52020fde3feb4c043a2b214e2.tar.gz
cpython-690b9355e00d1ea52020fde3feb4c043a2b214e2.tar.bz2
gh-121450: Make inline breakpoints use the most recent pdb instance (#121451)
Diffstat (limited to 'Lib/pdb.py')
-rw-r--r--Lib/pdb.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/Lib/pdb.py b/Lib/pdb.py
index 85a3aa2..7ff9731 100644
--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -306,6 +306,8 @@ class Pdb(bdb.Bdb, cmd.Cmd):
_file_mtime_table = {}
+ _last_pdb_instance = None
+
def __init__(self, completekey='tab', stdin=None, stdout=None, skip=None,
nosigint=False, readrc=True):
bdb.Bdb.__init__(self, skip=skip)
@@ -359,6 +361,12 @@ class Pdb(bdb.Bdb, cmd.Cmd):
self._chained_exceptions = tuple()
self._chained_exception_index = 0
+ def set_trace(self, frame=None):
+ Pdb._last_pdb_instance = self
+ if frame is None:
+ frame = sys._getframe().f_back
+ super().set_trace(frame)
+
def sigint_handler(self, signum, frame):
if self.allow_kbdint:
raise KeyboardInterrupt
@@ -2350,7 +2358,10 @@ def set_trace(*, header=None):
an assertion fails). If given, *header* is printed to the console
just before debugging begins.
"""
- pdb = Pdb()
+ if Pdb._last_pdb_instance is not None:
+ pdb = Pdb._last_pdb_instance
+ else:
+ pdb = Pdb()
if header is not None:
pdb.message(header)
pdb.set_trace(sys._getframe().f_back)