Repository navigation
Source location of return instruction in a with block is incorrect #98442
Copy link
Copy link
Closed
Labels
3.12only security fixesonly security fixesinterpreter-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 error
on Oct 19, 2022 - addedinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)3.12only security fixesonly security fixes
on Oct 19, 2022 - added a commit that references this issue
on Oct 19, 2022 - changed the title
[-]location of return instruction in a with block is incorrect[/-][+]Source locations of return instruction in a with block is incorrect[/+]on Oct 19, 2022 - changed the title
[-]Source locations of return instruction in a with block is incorrect[/-][+]Source location of return instruction in a with block is incorrect[/+]on Oct 19, 2022 @nedbat FYI.
This is now less wrong, but still there are instructions (in the
__exit__call) that span the whole body of the with-block:The return instruction takes its location from there, so it will be fixed once this is.
[((1, 1, 0, 0), 'RESUME', 0), ((2, 2, 6, 7), 'LOAD_GLOBAL', 'x'), ((2, 2, 6, 7), 'COPY', 1), ((2, 2, 6, 7), 'LOAD_SPECIAL', 1), ((2, 2, 6, 7), 'SWAP', 2), ((2, 2, 6, 7), 'SWAP', 3), ((2, 2, 6, 7), 'LOAD_SPECIAL', 0), ((2, 2, 6, 7), 'CALL', 0), ((2, 2, 6, 7), 'POP_TOP', None), ((3, 3, 10, 12), 'NOP', None), ((2, 3, 1, 12), 'LOAD_CONST', None), <-- Too wide ((2, 3, 1, 12), 'LOAD_CONST', None), ((2, 3, 1, 12), 'LOAD_CONST', None), ((2, 3, 1, 12), 'CALL', 3), ((2, 3, 1, 12), 'POP_TOP', None), ((2, 3, 1, 12), 'RETURN_CONST', 42), ((2, 2, 6, 7), 'PUSH_EXC_INFO', None), ((2, 2, 6, 7), 'WITH_EXCEPT_START', None), ((2, 2, 6, 7), 'TO_BOOL', None), ((2, 2, 6, 7), 'POP_JUMP_IF_TRUE', 70), ((2, 2, 6, 7), 'RERAISE', 2), ((2, 2, 6, 7), 'POP_TOP', None), ((2, 2, 6, 7), 'POP_EXCEPT', None), ((2, 2, 6, 7), 'POP_TOP', None), ((2, 2, 6, 7), 'POP_TOP', None), ((2, 2, 6, 7), 'POP_TOP', None), ((2, 2, 6, 7), 'RETURN_CONST', None), ((None, None, None, None), 'COPY', 3), ((None, None, None, None), 'POP_EXCEPT', None), ((None, None, None, None), 'RERAISE', 1)]With the fix in the PR we get:
[((1, 1, 0, 0), 'RESUME', 0), ((2, 2, 6, 7), 'LOAD_GLOBAL', 'x'), ((2, 2, 6, 7), 'COPY', 1), ((2, 2, 6, 7), 'LOAD_SPECIAL', 1), ((2, 2, 6, 7), 'SWAP', 2), ((2, 2, 6, 7), 'SWAP', 3), ((2, 2, 6, 7), 'LOAD_SPECIAL', 0), ((2, 2, 6, 7), 'CALL', 0), ((2, 2, 6, 7), 'POP_TOP', None), ((3, 3, 10, 12), 'NOP', None), ((2, 2, 6, 7), 'LOAD_CONST', None), ((2, 2, 6, 7), 'LOAD_CONST', None), ((2, 2, 6, 7), 'LOAD_CONST', None), ((2, 2, 6, 7), 'CALL', 3), ((2, 2, 6, 7), 'POP_TOP', None), ((2, 2, 6, 7), 'RETURN_CONST', 42), ((2, 2, 6, 7), 'PUSH_EXC_INFO', None), ((2, 2, 6, 7), 'WITH_EXCEPT_START', None), ((2, 2, 6, 7), 'TO_BOOL', None), ((2, 2, 6, 7), 'POP_JUMP_IF_TRUE', 70), ((2, 2, 6, 7), 'RERAISE', 2), ((2, 2, 6, 7), 'POP_TOP', None), ((2, 2, 6, 7), 'POP_EXCEPT', None), ((2, 2, 6, 7), 'POP_TOP', None), ((2, 2, 6, 7), 'POP_TOP', None), ((2, 2, 6, 7), 'POP_TOP', None), ((2, 2, 6, 7), 'RETURN_CONST', None), ((None, None, None, None), 'COPY', 3), ((None, None, None, None), 'POP_EXCEPT', None), ((None, None, None, None), 'RERAISE', 1)]Reacted by Maurice- added a commit that references this issue
on Jun 20, 2024 - added a commit that references this issue
on Sep 2, 2024 - added a commit that references this issue
on Sep 15, 2024
Metadata
Metadata
Assignees
Labels
3.12only security fixesonly security fixesinterpreter-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
Output:
Linked PRs