Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

No precise location provided for bytecode of lambda function returning a constant value #120722

Closed
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error
@blhsing

Description

@blhsing

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 theLOAD_CONST bytecode:

importdisf=lambda: ...forposinf.__code__.co_positions():print(*pos)dis.dis(f)

This outputs, in Python 3.11:

2 2 0 02 2 12 152 2 0 0  2           0 RESUME                   0              2 LOAD_CONST               1 (Ellipsis)              4 RETURN_VALUE

However, since Python 3.12, whereRETURN_CONST was introduced, the same code now outputs:

2 2 0 02 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 forRETURN_CONST in Python 3.12+:

importdisdeff():return ...forposinf.__code__.co_positions():print(*pos)dis.dis(f)

which outputs:

2 2 0 03 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp