Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
Closed as not planned
Labels
3.11only security fixesonly security fixes3.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
The instruction pointer f_lasti points under some conditions to a CACHE opcode.
This is not completely wrong, because this cache opcode comes after the expected CALL opcode, but the documetation says that CACHE opcodes should be skipped. Which it is not in this case.
script:
importinspectimportdisframe=inspect.currentframe() classTester: def__call__(self, f): deco(f) tester=Tester() defdeco(f): assertf.__name__=="foo"instructions=list(dis.get_instructions(frame.f_code, show_caches=True)) opname=instructions[frame.f_lasti//2].opnameprint(f"{frame.f_lasti=}\n{opname=}") assertopname=="CALL", opnameprint("correct") @testerdeffoo(): passprint() print("incorrect") @decodeffoo(): passoutput (Python 3.11.0rc2+):
correctframe.f_lasti=132opname='CALL'incorrectframe.f_lasti=204opname='CACHE'Traceback (mostrecentcalllast): File"/home/frank/projects/executing/example.py", line35, in<module> @deco^^^^File"/home/frank/projects/executing/example.py", line20, indecoassertopname=="CALL", opnameAssertionError: CACHEMetadata
Metadata
Assignees
Labels
3.11only security fixesonly security fixes3.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