diff options
author | David Douard <david.douard@logilab.fr> | 2009-10-08 12:37:30 +0200 |
---|---|---|
committer | David Douard <david.douard@logilab.fr> | 2009-10-08 12:37:30 +0200 |
commit | a1833732361ed38666b2fcaad4893ab5f6b78ec6 (patch) | |
tree | e4bda64141129bd58cb6a82a4f6938dbaa6df645 | |
parent | 95078ba52248efae2c126f3c411e86e45103b878 (diff) | |
download | logilab-common-a1833732361ed38666b2fcaad4893ab5f6b78ec6.tar.gz |
Add a "set_trace" function to debugger.py (to use in place of pdb.set_trace)
-rw-r--r-- | debugger.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/debugger.py b/debugger.py index 567c738..59bd0f8 100644 --- a/debugger.py +++ b/debugger.py @@ -74,11 +74,12 @@ class Debugger(Pdb): - overrides list command to search for current block instead of using 5 lines of context """ - def __init__(self, tcbk): + def __init__(self, tcbk=None): Pdb.__init__(self) self.reset() - while tcbk.tb_next is not None: - tcbk = tcbk.tb_next + if tcbk: + while tcbk.tb_next is not None: + tcbk = tcbk.tb_next self._tcbk = tcbk self._histfile = osp.join(os.environ["HOME"], ".pdbhist") @@ -187,3 +188,5 @@ def pm(): dbg = Debugger(sys.last_traceback) dbg.start() +def set_trace(): + Debugger().set_trace(sys._getframe().f_back) |