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

code.co_positions behaviour does not match documentation #100117

Closed
Labels
3.11only security fixes3.12only security fixes3.13bugs and security fixesdocsDocumentation in the Doc dirinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error
@iritkatriel

Description

@iritkatriel

Thedocumentation of co_positions() says:

The iterator returns tuples containing the (start_line, end_line, start_column, end_column). The i-th tuple corresponds to the position of the source code that compiled to the i-th instruction.

I think this is incorrect, because the iterator returns tuples for cache entries as well:

>>> def f():...   a.b = 1... >>> import dis>>> dis.dis(f)  1           0 RESUME                   0  2           2 LOAD_CONST               1 (1)              4 LOAD_GLOBAL              0 (a)             16 STORE_ATTR               1 (b)             26 LOAD_CONST               0 (None)             28 RETURN_VALUE>>> len(list(f.__code__.co_positions()))15>>> from pprint import pprint as pp>>> pp(list(f.__code__.co_positions()))[(1, 1, 0, 0), (2, 2, 8, 9), (2, 2, 2, 3), (2, 2, 2, 3), (2, 2, 2, 3), (2, 2, 2, 3), (2, 2, 2, 3), (2, 2, 2, 3), (2, 2, 2, 5), (2, 2, 2, 5), (2, 2, 2, 5), (2, 2, 2, 5), (2, 2, 2, 5), (2, 2, 2, 5), (2, 2, 2, 5)]>>>

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only security fixes3.12only security fixes3.13bugs and security fixesdocsDocumentation in the Doc dirinterpreter-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