Skip to content

Line numbers for errors off in traces #106290

Description

@gvanrossum

When a uop encounters an error, the line number is set to -1 or to the wrong place.

@markshannon


Repro (on latest main):

a = 1
def func():
global a
i = 20
while i > 0:
del a
i -= 1
if i >= 3:
a = 2
func()

Run this normally and you get this traceback:

Traceback (most recent call last):
File "/Users/guido/cpython/t.py", line 12, in <module>
func()
File "/Users/guido/cpython/t.py", line 7, in func
del a
^
NameError: name 'a' is not defined

But run with -Xuops, and you get:

Traceback (most recent call last):
File "/Users/guido/cpython/t.py", line 12, in <module>
func()
File "/Users/guido/cpython/t.py", line -1, in func
NameError: name 'a' is not defined

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions