Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LOAD_GLOBAL super reports wrong source positions #109195

Closed
15r10nk opened this issue Sep 9, 2023 · 1 comment · Fixed by #109291
Closed

LOAD_GLOBAL super reports wrong source positions #109195

15r10nk opened this issue Sep 9, 2023 · 1 comment · Fixed by #109291
Assignees
Labels
3.12 bugs and security fixes type-bug An unexpected behavior, bug, or error

Comments

@15r10nk
Copy link
Contributor

15r10nk commented Sep 9, 2023

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

@15r10nk 15r10nk added the type-bug An unexpected behavior, bug, or error label Sep 9, 2023
@AlexWaygood
Copy link
Member

I bisected this problem down to 0dc8b50

Cc. @carljm

@corona10 corona10 added the 3.12 bugs and security fixes label Sep 10, 2023
@carljm carljm self-assigned this Sep 11, 2023
carljm added a commit to carljm/cpython that referenced this issue Sep 11, 2023
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 11, 2023
…_ATTR (pythonGH-109289)

(cherry picked from commit ceeb417)

Co-authored-by: Carl Meyer <carl@oddbird.net>
Yhg1s pushed a commit that referenced this issue Sep 12, 2023
…R_ATTR (GH-109289) (#109291)

gh-109195: fix source location for super load before LOAD_SUPER_ATTR (GH-109289)
(cherry picked from commit ceeb417)

Co-authored-by: Carl Meyer <carl@oddbird.net>
@carljm carljm closed this as completed Sep 12, 2023
vstinner pushed a commit to vstinner/cpython that referenced this issue Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 bugs and security fixes type-bug An unexpected behavior, bug, or error
Projects
None yet
4 participants