gh-82987: Stop on calling frame unconditionally for inline breakpoints#130493
Merged
gaogaotiantian merged 6 commits intopython:mainfrom Mar 4, 2025
Merged
Conversation
tomasr8
reviewed
Feb 24, 2025
Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
iritkatriel
reviewed
Mar 3, 2025
Misc/NEWS.d/next/Library/2025-02-24-01-49-11.gh-issue-82987.vHfQlG.rst
Outdated
Show resolved
Hide resolved
| @@ -0,0 +1 @@ | |||
| :mod:`pdb` will always stop on calling frames when inline breakpoints like :func:`breakpoint` or :func:`pdb.set_trace` are used, regardless of whether the module matches ``skip`` pattern. | |||
Member
There was a problem hiding this comment.
This is probably worth a what's new entry.
Member
There was a problem hiding this comment.
And a versionchange comment in the doc?
…fQlG.rst Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
iritkatriel
reviewed
Mar 3, 2025
Doc/library/pdb.rst
Outdated
| Added the *mode* argument. | ||
|
|
||
| .. versionchanged:: 3.14 | ||
| *skip* will be ignored if inline breakpoints like :func:`breakpoint` or :func:`set_trace` are used. |
Member
There was a problem hiding this comment.
"if ... are used" could be misunderstood to mean that skip will always be ignored if those are ever used.
Member
Author
There was a problem hiding this comment.
Will changing it to "when ... are used" better? Or we should just use the longer version from the news entry?
Member
There was a problem hiding this comment.
I think "when .. are used" has the same problem, as does the longer version from the news entry.
Member
Author
There was a problem hiding this comment.
Inline breakpoints like :func:`breakpoint` or :func:`pdb.set_trace` will always stop the program at calling frame, ignoring the ``skip`` pattern (if any).
Is this better?
Member
Author
There was a problem hiding this comment.
Then I'll use this for all 3 places :)
iritkatriel
approved these changes
Mar 4, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The testing code
seems a bit silly, but this is a real issue because we use the last instance of pdb for inline breakpoints now.
So if we instantiate a debugger like
p = pdb.Pdb(skip=["django.*"])somewhere, and we set an inline breakpoint in Django with an innocentbreakpoint(), it still won't stop inside Django modules.Overall I think it's reasonable that we always stop for inline breakpoints. The implementation I chose is to remove the condition for
opcodeevents which also makes sense. For now that event is exclusively used by inline breakpoints. Even if we add instruction level debugging in the future, I think the only useful command is "step instruction". It's hard to imagine instruction level breakpoints or something likeuntil instruction. Always trigger user function for opcode seems like an okay solution.