Content-Length: 306373 | pFad | https://github.com/python/cpython/issues/105724

B9 Improve the error message for `assert` and `AssertionError` by adding location information · Issue #105724 · python/cpython · GitHub
Skip to content

Improve the error message for assert and AssertionError by adding location information #105724

@sobolevn

Description

@sobolevn

Feature or enhancement

Right now assert generate errors that are hard to read, mostly because they lack context.
Example:

>>> assert 1 == 0
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AssertionError

Pitch

Let's make them better:

>>> assert 1 == 0
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
    assert 1 == 0
           ^^^^^^
AssertionError

This is a good starting point.

Later this can be enhanced to use more context.

Linked PRs

Metadata

Metadata

Assignees

Labels

interpreter-core(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancement

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions









    ApplySandwichStrip

    pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


    --- a PPN by Garber Painting Akron. With Image Size Reduction included!

    Fetched URL: https://github.com/python/cpython/issues/105724

    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy