Bug report
Bug description:
LOAD_DEREF is missing the HAS_FREE_FLAG within pycore_opcode_metadata.h and has the HAS_LOCAL_FLAG set, although it only access freevars not locals, this leads to incorrect behaviour with dis.hasfree().
LOAD_CLOSURE has the same incorrect flags.
This behavior is correct in python3.12, in python3.13 only LOAD_CLOSURE is missing the correct flags.
from the docs:
dis.hasfree():
Sequence of bytecodes that access a free (closure) variable. ‘free’ in this context refers to names in the current scope that are referenced by inner scopes or names in outer scopes that are referenced from this scope. It does not include references to global or builtin scopes.
Minimal Example
import dis
for instr in dis.hasfree:
print(dis.opname[instr])
Expected Behavior:
DELETE_DEREF
LOAD_CLOSURE
LOAD_DEREF
LOAD_FROM_DICT_OR_DEREF
MAKE_CELL
STORE_DEREF
Actual Behavior:
DELETE_DEREF
LOAD_FROM_DICT_OR_DEREF
MAKE_CELL
STORE_DEREF
CPython versions tested on:
3.15, 3.14, 3.13, 3.12, Main
Operating systems tested on:
Linux
Linked PRs
Bug report
Bug description:
LOAD_DEREF is missing the HAS_FREE_FLAG within pycore_opcode_metadata.h and has the HAS_LOCAL_FLAG set, although it only access freevars not locals, this leads to incorrect behaviour with dis.hasfree().
LOAD_CLOSURE has the same incorrect flags.
This behavior is correct in python3.12, in python3.13 only LOAD_CLOSURE is missing the correct flags.
from the docs:
Minimal Example
Expected Behavior:
Actual Behavior:
CPython versions tested on:
3.15, 3.14, 3.13, 3.12, Main
Operating systems tested on:
Linux
Linked PRs