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

Merged
merged 4 commits into from Sep 15, 2016

Conversation

Projects
None yet
3 participants
@tillahoffmann
Contributor

tillahoffmann commented Sep 14, 2016

This PR adds a set_trace method to IPython.core.debugger to mirror the functionality of IPython.terminal.debugger. See #9940 for a discussion.

Show outdated Hide outdated IPython/core/debugger.py
@@ -621,3 +621,14 @@ def do_where(self, arg):
self.print_stack_trace()
do_w = do_where
def set_trace(frame=None, condition=True):

This comment has been minimized.

@takluyver

takluyver Sep 14, 2016

Member

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.

@takluyver

takluyver Sep 14, 2016

Member

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.

Show outdated Hide outdated IPython/core/debugger.py
If frame is not specified, debugging starts from caller's frame.
"""
if condition:
pdb = Pdb()

This comment has been minimized.

@tillahoffmann

tillahoffmann Sep 14, 2016

Contributor

These shouldn't be tabs. Will fix in next commit.

@tillahoffmann

tillahoffmann Sep 14, 2016

Contributor

These shouldn't be tabs. Will fix in next commit.

@@ -621,3 +621,13 @@ def do_where(self, arg):
self.print_stack_trace()
do_w = do_where
def set_trace(frame=None):

This comment has been minimized.

@takluyver

takluyver Sep 14, 2016

Member

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 ;-)

@takluyver

takluyver Sep 14, 2016

Member

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 ;-)

This comment has been minimized.

@tillahoffmann

tillahoffmann Sep 14, 2016

Contributor

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.

@tillahoffmann

tillahoffmann Sep 14, 2016

Contributor

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.

This comment has been minimized.

@takluyver

takluyver Sep 14, 2016

Member

I could go either way, but I'd like to know what @Carreau thinks when he's online in a couple more hours. :-)

@takluyver

takluyver Sep 14, 2016

Member

I could go either way, but I'd like to know what @Carreau thinks when he's online in a couple more hours. :-)

This comment has been minimized.

@Carreau

Carreau Sep 14, 2016

Member

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.

@Carreau

Carreau Sep 14, 2016

Member

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.

This comment has been minimized.

@takluyver

takluyver Sep 14, 2016

Member

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)
@takluyver

takluyver Sep 14, 2016

Member

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)
@Carreau

Seem good to me ! (trying new GitHub reviews things)

@Carreau Carreau added this to the 5.2 milestone Sep 15, 2016

@Carreau

This comment has been minimized.

Show comment
Hide comment
@Carreau

Carreau Sep 15, 2016

Member

Marking as 5.2 as it should be easy to backport.

Member

Carreau commented Sep 15, 2016

Marking as 5.2 as it should be easy to backport.

@takluyver

This comment has been minimized.

Show comment
Hide comment
@takluyver

takluyver Sep 15, 2016

Member

Looks good, thanks @tillahoffmann

Member

takluyver commented Sep 15, 2016

Looks good, thanks @tillahoffmann

@takluyver takluyver merged commit 185e47e into ipython:master Sep 15, 2016

3 checks passed

codecov/patch 60.00% of diff hit (target 0.00%)
Details
codecov/project 73.18% (+<.01%) compared to 41bc8e5
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@Carreau Carreau referenced this pull request Sep 18, 2016

Merged

Bunch of 5.x backport. #9959

takluyver added a commit that referenced this pull request Jan 12, 2017

Backport PR #9947: Add set_trace to core debugger.
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment