Skip to content

Commit

Permalink
Add condition parameter to debug with better ease
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrebarbaruiva authored and gotcha committed Jun 23, 2020
1 parent 5a263c7 commit bdcda7e
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions ipdb/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,18 @@ def wrap_sys_excepthook():
sys.excepthook = BdbQuit_excepthook


def set_trace(frame=None, context=None):
wrap_sys_excepthook()
if not context:
context = os.environ.get(
"IPDB_CONTEXT_SIZE", get_context_from_config()
)
if frame is None:
frame = sys._getframe().f_back
p = _init_pdb(context).set_trace(frame)
if p and hasattr(p, 'shell'):
p.shell.restore_sys_module_state()
def set_trace(frame=None, context=None, cond=True):
if cond:
wrap_sys_excepthook()
if not context:
context = os.environ.get(
"IPDB_CONTEXT_SIZE", get_context_from_config()
)
if frame is None:
frame = sys._getframe().f_back
p = _init_pdb(context).set_trace(frame)
if p and hasattr(p, 'shell'):
p.shell.restore_sys_module_state()


def get_context_from_config():
Expand Down

0 comments on commit bdcda7e

Please sign in to comment.