In 3.12 findlinestarts seems to return None for line more often#1721
Merged
rchiodo merged 1 commit intomicrosoft:mainfrom Nov 4, 2024
Merged
In 3.12 findlinestarts seems to return None for line more often#1721rchiodo merged 1 commit intomicrosoft:mainfrom
rchiodo merged 1 commit intomicrosoft:mainfrom
Conversation
debonte
approved these changes
Nov 4, 2024
debonte
reviewed
Nov 4, 2024
| min_line = sys.maxsize | ||
| for _, line in dis.findlinestarts(code_obj): | ||
| if line > max_line: | ||
| if line is not None and line > max_line: |
There was a problem hiding this comment.
I'm confused about how line can be None since dis.findlinestarts checks for None before yielding.
Contributor
Author
There was a problem hiding this comment.
I'm not sure what makes you say that? The docs at least say it can be none. dis.findlinestarts is supposed to call: https://docs.python.org/3/reference/datamodel.html#codeobject.co_lines.
I didn't check the source in CPython though
There was a problem hiding this comment.
Oh, I didn't notice that it wasn't our code. I just used "go to def"` and saw this. Turns out this is from my CPython 3.12.7 install.
def findlinestarts(code):
"""Find the offsets in a byte code which are start of lines in the source.
Generate pairs (offset, lineno)
"""
lastline = None
for start, end, line in code.co_lines():
if line is not None and line != lastline:
lastline = line
yield start, line
return
Contributor
Author
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
rchiodo
added a commit
to rchiodo/debugpy
that referenced
this pull request
Nov 14, 2024
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.
Fixes #1720