Skip to content

Commit

Permalink
ipdb: accept header= argument (ipython#14289)
Browse files Browse the repository at this point in the history
This improves symmetry between Ipdb and vanilla old Pdb.

The `header` argument to `pdb.set_trace()` [has been added in Python
3.7](https://docs.python.org/3.9/whatsnew/3.7.html#pdb).

_(This still requires changes in
[gotcha/ipdb](https://github.com/gotcha/ipdb) to be fully useful - I'll
get to that later 😉)_
  • Loading branch information
Carreau authored Jan 14, 2024
2 parents 0cfa5ab + 16f84c6 commit 8889ec7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions IPython/core/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -1111,10 +1111,13 @@ def _cmdloop(self):
raise


def set_trace(frame=None):
def set_trace(frame=None, header=None):
"""
Start debugging from `frame`.
If frame is not specified, debugging starts from caller's frame.
"""
Pdb().set_trace(frame or sys._getframe().f_back)
pdb = Pdb()
if header is not None:
pdb.message(header)
pdb.set_trace(frame or sys._getframe().f_back)

0 comments on commit 8889ec7

Please sign in to comment.