Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
18e6e9c
Allow using sys.monitoring for bdb
gaogaotiantian Sep 25, 2024
b29aff5
Add basic line ignore
gaogaotiantian Sep 25, 2024
23601f3
Use setttrace as default backend for bdb
gaogaotiantian Sep 25, 2024
c9a92f6
📜🤖 Added by blurb_it.
blurb-it[bot] Sep 25, 2024
8955d78
Use settrace by default for pdb.Pdb, but use monitoring for all
gaogaotiantian Sep 26, 2024
6afc2e7
Only trigger events on thread calling start_trace
gaogaotiantian Oct 16, 2024
b595682
Use local events when possible
gaogaotiantian Oct 16, 2024
addf465
Merge branch 'main' into pdb-use-monitoring
gaogaotiantian Jan 19, 2025
70d5138
Fix ignore and condition of breakpoints
gaogaotiantian Feb 8, 2025
7c83425
Merge branch 'main' into pdb-use-monitoring
gaogaotiantian Feb 8, 2025
fe9971c
Address comments about backend
gaogaotiantian Feb 18, 2025
69a5030
Merge branch 'main' into pdb-use-monitoring
gaogaotiantian Feb 18, 2025
05cc3b0
We need BaseException to handle SystemExit case
gaogaotiantian Feb 18, 2025
e6bc287
Move default_backend to module level and provide utils
gaogaotiantian Feb 19, 2025
f0c1306
Do not need to pass trace_dispatch explicitly
gaogaotiantian Feb 19, 2025
a9b53ed
Add docs
gaogaotiantian Feb 19, 2025
9790085
Add version added
gaogaotiantian Feb 19, 2025
ea811f2
Add new functions to __all__
gaogaotiantian Feb 19, 2025
ad2179e
Merge branch 'main' into pdb-use-monitoring
gaogaotiantian Mar 7, 2025
e4ccd8a
Restart events after user line
gaogaotiantian Mar 7, 2025
d2c1f2e
Merge branch 'main' into pdb-use-monitoring
gaogaotiantian Mar 17, 2025
e9252ec
Remove blank line
gaogaotiantian Mar 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use settrace by default for pdb.Pdb, but use monitoring for all
direct pdb usage
  • Loading branch information
gaogaotiantian committed Jan 17, 2025
commit 8955d78969ceacddfbb76ea8046d7f2b9fc8da50
9 changes: 5 additions & 4 deletions Lib/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,15 @@ class Pdb(bdb.Bdb, cmd.Cmd):
# Limit the maximum depth of chained exceptions, we should be handling cycles,
# but in case there are recursions, we stop at 999.
MAX_CHAINED_EXCEPTION_DEPTH = 999
DEFAULT_BACKEND = 'settrace'

_file_mtime_table = {}

_last_pdb_instance = None

def __init__(self, completekey='tab', stdin=None, stdout=None, skip=None,
nosigint=False, readrc=True, mode=None):
bdb.Bdb.__init__(self, skip=skip, backend='monitoring')
nosigint=False, readrc=True, mode=None, backend=None):
Copy link
Copy Markdown
Member

@markshannon markshannon Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

backend=Pdb.DEFAULT_BACKEND to avoid the need for the conditional expression on the next line.

That wouldn't work because DEFAULT_BACKEND is not a constant.

bdb.Bdb.__init__(self, skip=skip, backend=backend if backend else self.DEFAULT_BACKEND)
cmd.Cmd.__init__(self, completekey, stdin, stdout)
sys.audit("pdb.Pdb")
if stdout:
Expand Down Expand Up @@ -2376,7 +2377,7 @@ def set_trace(*, header=None, commands=None):
if Pdb._last_pdb_instance is not None:
pdb = Pdb._last_pdb_instance
else:
pdb = Pdb(mode='inline')
pdb = Pdb(mode='inline', backend='monitoring')
if header is not None:
pdb.message(header)
pdb.set_trace(sys._getframe().f_back, commands=commands)
Expand Down Expand Up @@ -2507,7 +2508,7 @@ def main():
# modified by the script being debugged. It's a bad idea when it was
# changed by the user from the command line. There is a "restart" command
# which allows explicit specification of command line arguments.
pdb = Pdb(mode='cli')
pdb = Pdb(mode='cli', backend='monitoring')
pdb.rcLines.extend(opts.commands)
while True:
try:
Expand Down
8 changes: 7 additions & 1 deletion Lib/test/test_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -4339,7 +4339,13 @@ def test_multiline_completion(self):

def load_tests(loader, tests, pattern):
from test import test_pdb
tests.addTest(doctest.DocTestSuite(test_pdb))
def setUpPdbBackend(backend):
def setUp(test):
import pdb
pdb.Pdb.DEFAULT_BACKEND = backend
return setUp
tests.addTest(doctest.DocTestSuite(test_pdb, setUp=setUpPdbBackend('monitoring')))
tests.addTest(doctest.DocTestSuite(test_pdb, setUp=setUpPdbBackend('settrace')))
return tests


Expand Down