Skip to content

Commit

Permalink
Make pdb.orig_set_trace available
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed committed May 25, 2019
1 parent 1bef719 commit 84ce69c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pdb.py
Expand Up @@ -81,6 +81,11 @@ def import_from_stdlib(name):

pdb = import_from_stdlib('pdb')

# Make the original pdb's set_trace available, for e.g.
# PYTHONBREAKPOINT=pdb.orig_set_trace.
# It does not handle "pdb.pdb.set_trace" there.
orig_set_trace = pdb.set_trace


def rebind_globals(func, newglobals):
newfunc = types.FunctionType(func.__code__, newglobals, func.__name__,
Expand Down
15 changes: 15 additions & 0 deletions testing/test_pdb.py
Expand Up @@ -3928,3 +3928,18 @@ class Config(ConfigTest):
\d\d pass
# c
""")


def test_orig_pdb_set_trace():
def fn():
set_trace()

check(fn, """
--Return-
[NUM] > .*fn()
-> set_trace()
5 frames hidden .*
# import pdb
# assert pdb.orig_set_trace is pdb.pdb.set_trace
# c
""")

0 comments on commit 84ce69c

Please sign in to comment.