Skip to content

Improve tracebacks for C functions (pass information about arguments) #124819

@skirpichev

Description

@skirpichev

Feature or enhancement

Proposal:

Right now tracebacks look like this:

>>> math.log(2,-2)
Traceback (most recent call last):
  File "<python-input-1>", line 1, in <module>
    math.log(2,-2)
    ~~~~~~~~^^^^^^
ValueError: expected a positive input

i.e. the whole list of parameters is highlighted.

But in many cases errors in C functions coming e.g. from input validation and related to very specific argument. I think we can pass this additional information with exception to get traceback like this instead:

>>> math.log(2,-2)
Traceback (most recent call last):
  File "<python-input-1>", line 1, in <module>
    math.log(2,-2)
    ~~~~~~~~   ^^
ValueError: expected a positive input

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions