Repository navigation
code.co_positions behaviour does not match documentation #100117
Copy link
Copy link
Closed
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixes3.13only security fixesonly security fixesdocsDocumentation in the Doc dirDocumentation in the Doc dirinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Activity
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or errordocsDocumentation in the Doc dirDocumentation in the Doc dirinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)3.11only security fixesonly security fixes3.12only security fixesonly security fixes
on Dec 8, 2022 - changed the title
[-]error documentation of code.co_positions[/-][+]error in documentation of code.co_positions[/+]on Dec 8, 2022 - changed the title
[-]error in documentation of code.co_positions[/-][+]code.co_positions behaviour does not match documentation[/+]on Dec 12, 2022 I think this is probably just a place where the docs could be improved.
Are you suggesting replacing "instruction" with "code unit"? Or adding a note that inline
CACHE"instructions" are included? I'd be fine with either.We discussed this at the meeting and I think the view was that the implementation needs to change. @markshannon ?
I don't think we can change the current behavior of emitting one tuple per code unit . The docs should reflect that behaviour.
I think it is
co_lines()that we should modify. We can merge successive tuples with the same line number, now that #99556 is merged.This shouldn't have been closed, the doc is still incorrect.
- added a commit that references this issue
on May 31, 2024 - added 3 commits that reference this issue
on May 31, 2024 - added a commit that references this issue
on Sep 4, 2024
Metadata
Metadata
Assignees
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixes3.13only security fixesonly security fixesdocsDocumentation in the Doc dirDocumentation in the Doc dirinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
The documentation of co_positions() says:
The iterator returns tuples containing the (start_line, end_line, start_column, end_column). The i-th tuple corresponds to the position of the source code that compiled to the i-th instruction.I think this is incorrect, because the iterator returns tuples for cache entries as well:
Linked PRs
co_linesmore efficient #100447