Thanks to visit codestin.com
Credit goes to github.com

Skip to content

LOAD_GLOBAL super reports wrong source positions #109195

Closed
@15r10nk

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

Metadata

Metadata

Assignees

Labels

3.12only security fixestype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions