-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add set_trace to core debugger. #9947
Conversation
@@ -621,3 +621,14 @@ def do_where(self, arg): | |||
self.print_stack_trace() | |||
|
|||
do_w = do_where | |||
|
|||
|
|||
def set_trace(frame=None, condition=True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's stick to the same API as pdb
and IPython.terminal.debugger
, with set_trace()
taking no parameters. We can discuss adding parameters as a separate step, and if we do we'll want to keep core
and terminal
in sync.
@@ -621,3 +621,13 @@ def do_where(self, arg): | |||
self.print_stack_trace() | |||
|
|||
do_w = do_where | |||
|
|||
|
|||
def set_trace(frame=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other set_trace()
functions also don't have a frame
parameter, though the set_trace()
method does. I'd either remove it from here, or also add it to the version in IPython.terminal
. @Carreau, opinions?
Also, if we decide to keep the parameter, it should probably actually do something ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it should indeed do something. Let me know if you'd prefer to remove the frame
parameter or add it to IPython.terminal
as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could go either way, but I'd like to know what @Carreau thinks when he's online in a couple more hours. :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to add it to the function, it should likely be passed to Pdb.set_trace()
by adding 1 to it, and we should even likely start the debugging 1 frame up from the current one to be consistent with normal Pdb.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, though it takes a frame object, not an offset number. Here's the set_trace
definition from pdb:
def set_trace():
Pdb().set_trace(sys._getframe().f_back)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seem good to me ! (trying new GitHub reviews things)
Marking as 5.2 as it should be easy to backport. |
Looks good, thanks @tillahoffmann |
This PR adds a `set_trace` method to `IPython.core.debugger` to mirror the functionality of `IPython.terminal.debugger`. See 9940 for a discussion. Signed-off-by: Thomas Kluyver <thomas@kluyver.me.uk>
This PR adds a
set_trace
method toIPython.core.debugger
to mirror the functionality ofIPython.terminal.debugger
. See #9940 for a discussion.