Thanks to visit codestin.com
Credit goes to github.com

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
Move default_backend to module level and provide utils
  • Loading branch information
gaogaotiantian committed Feb 19, 2025
commit e6bc28774f31c39d5141f901ed97c787bd1cf867
20 changes: 18 additions & 2 deletions Lib/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,22 +301,38 @@ def write(self, data):
line_prefix = '\n-> ' # Probably a better default


# The default backend to use for Pdb instances if not specified
# Should be either 'settrace' or 'monitoring'
_default_backend = 'settrace'


def set_default_backend(backend):
"""Set the default backend to use for Pdb instances."""
global _default_backend
if backend not in ('settrace', 'monitoring'):
raise ValueError("Invalid backend: %s" % backend)
_default_backend = backend


def get_default_backend():
"""Get the default backend to use for Pdb instances."""
return _default_backend


class Pdb(bdb.Bdb, cmd.Cmd):
_previous_sigint_handler = None

# 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, 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)
bdb.Bdb.__init__(self, skip=skip, backend=backend if backend else get_default_backend())
cmd.Cmd.__init__(self, completekey, stdin, stdout)
sys.audit("pdb.Pdb")
if stdout:
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -4449,7 +4449,7 @@ def load_tests(loader, tests, pattern):
def setUpPdbBackend(backend):
def setUp(test):
import pdb
pdb.Pdb.DEFAULT_BACKEND = backend
pdb.set_default_backend(backend)
return setUp
tests.addTest(doctest.DocTestSuite(test_pdb, setUp=setUpPdbBackend('monitoring')))
tests.addTest(doctest.DocTestSuite(test_pdb, setUp=setUpPdbBackend('settrace')))
Expand Down