Skip to content

LOAD_GLOBAL super reports wrong source positions #109195

Closed

Description

@15r10nk

Bug report

Bug description:

LOAD_GLOBAL super includes the paranthesis of super() in the source positions.

script:

import dis

source="""
class VerifierFailure:

    def __init__(self):
        super().__init__
"""

code=compile(source,"<file>","exec")

bc=code.co_consts[0].co_consts[1]

load_global=list(dis.Bytecode(bc))[2]

dis.dis(bc)

print(load_global)

assert load_global.positions.end_col_offset==13

output (Python 3.12.0rc2+):

              0 COPY_FREE_VARS           1

  4           2 RESUME                   0

  5           4 LOAD_GLOBAL              0 (super)
             14 LOAD_DEREF               1 (__class__)
             16 LOAD_FAST                0 (self)
             18 LOAD_SUPER_ATTR          4 (__init__)
             22 POP_TOP
             24 RETURN_CONST             0 (None)
Instruction(opname='LOAD_GLOBAL', opcode=116, arg=0, argval='super', argrepr='super', offset=4, starts_line=5, is_jump_target=False, positions=Positions(lineno=5, end_lineno=5, col_offset=8, end_col_offset=15))
Traceback (most recent call last):
  File "/home/frank/projects/cpython/../executing/bug.py", line 21, in <module>
    assert load_global.positions.end_col_offset==13
AssertionError

I bisected this problem down to 0dc8b50

I hope that it is possible to restore the old source positions. I work currently on python 3.12 support for executing, which relies on correct source positions to perform a correct bytecode -> AST mapping.

CPython versions tested on:

3.12

Operating systems tested on:

Linux

Linked PRs

Activity

  1. added
    type-bug
    on Sep 9, 2023
  2. AlexWaygood commented on Sep 9, 2023

    @AlexWaygood
    Member

    I bisected this problem down to 0dc8b50

    Cc. @carljm

  3. added
    3.12
    on Sep 10, 2023
  4. self-assigned this
    on Sep 11, 2023
  5. added 2 commits that reference this issue on Sep 11, 2023
  6. added a commit that references this issue on Sep 11, 2023
  7. added a commit that references this issue on Sep 12, 2023
  8. added a commit that references this issue on Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

3.12type-bug

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions