Skip to content

PEP657 Column position of raised exceptions #1099

@tonybaloney

Description

@tonybaloney

In Debugpy, exceptions raised in Python 3.11 are missing the fine-grained position:

For example, in the following code:

d = {
    "x": {
        "y": {
            "z": {
                "theta": 1
            }
        }
    }
}

result = d["x"]["y"]["z"]["beta"]

On the CLI I get the position of the KeyError offset in the line underlined using PEP657 API:

$ python exploding_kitten.py
...
  File "/Users/anthonyshaw/tmp/exploding_kitten.py", line 11, in <module>
    result = d["x"]["y"]["z"]["beta"]
             ~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'beta'

But in VS Code it only highlights the line and not the position of the exception, making it harder to work out where the error came from.

screenshot 2022-10-25 at 13 33 54

Please can PEP657 be implemented in debugpy so that the Stopped event sent back via DAP include the position (start col, end col) of the raised exception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions