Skip to content

Commit 846ea9c

Browse files
committed
bpdb: add post_mortem() and pm() functions for compability
This makes better post-mortem debugging using BPdb as easy as try: import bpdb as pdb except ImportError: import pdb Closes #209
1 parent b58f201 commit 846ea9c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

bpdb/__init__.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,22 @@ def set_trace():
3434
a debugger instance and sets the trace. """
3535
debugger = BPdb()
3636
debugger.set_trace(sys._getframe().f_back)
37+
38+
# Adopted verbatim from pdb for completeness:
39+
40+
def post_mortem(t=None):
41+
# handling the default
42+
if t is None:
43+
# sys.exc_info() returns (type, value, traceback) if an exception is
44+
# being handled, otherwise it returns None
45+
t = sys.exc_info()[2]
46+
if t is None:
47+
raise ValueError("A valid traceback must be passed if no "
48+
"exception is being handled")
49+
50+
p = BPdb()
51+
p.reset()
52+
p.interaction(None, t)
53+
54+
def pm():
55+
post_mortem(getattr(sys, "last_traceback", None))

0 commit comments

Comments
 (0)