Skip to content
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

Make recursive pdb properly invoke IPython's enhanced pdb #10721

Merged
merged 1 commit into from Sep 13, 2017

Conversation

@segevfiner
Copy link
Contributor

segevfiner commented Jul 29, 2017

The problem is that Pdb.do_debug creates a new instance of the original Pdb rather than our derived Pdb/TerminalPdb. So I copied Lib/pdb.py:1087-1102 and made it use our own class instead.

I had to:

  1. Switch to keyword arguments because IPython changes Pdb's init signature.
  2. Add a line to propagate use_rawinput. Without that the propagation of stdout triggers use_rawinput = 0, breaking TerminalPdb. This is probably a bug in Python, see: bpo-31078.

For IPython 5, the self.message lines need to be changed to a print. See Lib/pdb.py:712-722 (2.7).

  • Do we want to change the nested Pdb's prompt calculation? Now it uses (ipdb>) , adding more parentheses to each nesting level (Pdb's default prompt is (Pdb) ).

Fixes #1273

@takluyver
Copy link
Member

takluyver commented Jul 31, 2017

Thanks! I've milestoned it for 6.2 as a new feature, so the self.message() statements should be fine.

Like Fernando back in 2012, I had no idea that recursive pdb was a thing, so whatever you think makes sense for the prompt is fine by me!

@Carreau
Copy link
Member

Carreau commented Sep 13, 2017

@segevfiner is that good as is ? I'm happy to get it into 6.2, or do you want to add extra things like the prompt ?

@segevfiner
Copy link
Contributor Author

segevfiner commented Sep 13, 2017

The prompt is a matter of taste. pdb's prompt is (Pdb) and when you invoke it recursively, it changes into ((Pdb)) with more parentheses added for each level of recursion. ipdb uses ipdb> and since I left that calculation as is, it will use (ipdb>) when invoked recursively. Unless you prefer some other prompt for the recursive invocation, than this PR is ready.

@Carreau
Copy link
Member

Carreau commented Sep 13, 2017

The prompt is a matter of taste. pdb's prompt is (Pdb) and when you invoke it recursively, it changes into ((Pdb)) with more parentheses added for each level of recursion. ipdb uses ipdb> and since I left that calculation as is, it will use (ipdb>) when invoked recursively. Unless you prefer some other prompt for the recursive invocation, than this PR is ready.

ok, perfect, thank you, sorry for the delay them from the overview in the PR list there was a "0 out of 1", and though you wanted to add something.

Merging.

@Carreau Carreau merged commit a141a93 into ipython:master Sep 13, 2017
4 checks passed
4 checks passed
codecov/patch 8.33% of diff hit (target 0%)
Details
codecov/project 66.93% (-0.04%) compared to 907885b
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@segevfiner segevfiner deleted the segevfiner:recursive-ipdb branch Sep 14, 2017
Carreau added a commit to Carreau/ipython that referenced this pull request Sep 15, 2017
Carreau added a commit to Carreau/ipython that referenced this pull request Sep 15, 2017
takluyver added a commit that referenced this pull request Sep 15, 2017
Add what's new for PR #10721
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.