-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-59013: Set breakpoint on the first executable line in pdb when using break func
#112470
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
Merged
+61
−22
Conversation
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
Hi @iritkatriel , do you have some time to take a look at this PR? Basically this tries to locate the first line of the function when the user |
iritkatriel
reviewed
Jan 30, 2024
Misc/NEWS.d/next/Library/2023-11-27-19-54-43.gh-issue-59013.chpQ0e.rst
Outdated
Show resolved
Hide resolved
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
iritkatriel
reviewed
Jan 30, 2024
iritkatriel
approved these changes
Jan 31, 2024
aisk
pushed a commit
to aisk/cpython
that referenced
this pull request
Feb 11, 2024
…on when using `break func` in pdb (python#112470)
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.
In #110582, we made
break foo
work iffoo
is already a known function (that has an associated code object). However, iffoo
is in another module or it's not defined yet, we still use regular expression to find the definition, which will still set the breakpoint on thedef
line. This is an inconsistent behavior and will confuse users because the actual break will be on the first executable line.This PR solves the issue by trying to compile the head of function to find the first executable line. As long as the first couple of lines are compilable, we should be able to find the first executable line of the function and set the break point on it. This skips comments, empty lines well (and not using pure strings to figure it out).
Notably, this is a breaking change - because the previous behavior is confusing.