Bug report
Bug description:
In Python 3.11, the code object of a lambda function that returns a constant value used to have location information provided for the LOAD_CONST bytecode:
import dis
f = lambda: ...
for pos in f.__code__.co_positions():
print(*pos)
dis.dis(f)
This outputs, in Python 3.11:
2 2 0 0
2 2 12 15
2 2 0 0
2 0 RESUME 0
2 LOAD_CONST 1 (Ellipsis)
4 RETURN_VALUE
However, since Python 3.12, where RETURN_CONST was introduced, the same code now outputs:
2 2 0 0
2 2 0 0
2 RESUME 0
RETURN_CONST 1 (Ellipsis)
with no precise location information found in any of the bytecode produced.
Note that a regular function that returns a constant value correctly provides precise location information for RETURN_CONST in Python 3.12+:
import dis
def f():
return ...
for pos in f.__code__.co_positions():
print(*pos)
dis.dis(f)
which outputs:
2 2 0 0
3 3 11 14
2 RESUME 0
3 RETURN_CONST 1 (Ellipsis)
CPython versions tested on:
3.11, 3.12, CPython main branch
Operating systems tested on:
Linux, Windows
Linked PRs
Bug report
Bug description:
In Python 3.11, the code object of a lambda function that returns a constant value used to have location information provided for the
LOAD_CONSTbytecode:This outputs, in Python 3.11:
However, since Python 3.12, where
RETURN_CONSTwas introduced, the same code now outputs:with no precise location information found in any of the bytecode produced.
Note that a regular function that returns a constant value correctly provides precise location information for
RETURN_CONSTin Python 3.12+:which outputs:
CPython versions tested on:
3.11, 3.12, CPython main branch
Operating systems tested on:
Linux, Windows
Linked PRs