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

PEP-657 enhanced error locations in pytest tracebacks #10224

Open
davidszotten opened this issue Aug 16, 2022 · 5 comments
Open

PEP-657 enhanced error locations in pytest tracebacks #10224

davidszotten opened this issue Aug 16, 2022 · 5 comments
Labels
status: help wanted developers would like help from experts on this topic topic: tracebacks related to displaying and handling of tracebacks type: enhancement new feature or API change, should be merged into features branch

Comments

@davidszotten
Copy link
Contributor

Hi. Are there any plans to support PEP-657 style enhanced tracebacks when on py 3.11? with some pointers i'd be happy to look at implemetation

@nicoddemus
Copy link
Member

Hi @davidszotten,

There's #10209 open to at least fall back to native traceback printing temporarily, #9159 tracks the full support.

@davidszotten
Copy link
Contributor Author

hi @nicoddemus , thanks for the quick reply. just to be clear, i'm talking about

https://docs.python.org/3.11/whatsnew/3.11.html#enhanced-error-locations-in-tracebacks

Traceback (most recent call last):
  File "distance.py", line 11, in <module>
    print(manhattan_distance(p1, p2))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "distance.py", line 6, in manhattan_distance
    return abs(point_1.x - point_2.x) + abs(point_1.y - point_2.y)
                           ^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'x'

not exception groups. or are the two tied together?

@nicoddemus
Copy link
Member

🤦 Sorry indeed they are not related, sorry for the confusion.

I don't think we have any plans regarding that (a quick search did not turn out much), but this is something we should definitely look into.

@nicoddemus
Copy link
Member

Btw you asked for pointers: the traceback printing code starts in ExceptionRepr.toterminal, it should be possible to figure out/understand the code from there.

@Zac-HD Zac-HD changed the title PEP-657 enhanced tracebacks PEP-657 enhanced error locations in Pytest tracebacks Aug 17, 2022
@Zac-HD Zac-HD added type: enhancement new feature or API change, should be merged into features branch topic: tracebacks related to displaying and handling of tracebacks labels Aug 17, 2022
@Zac-HD
Copy link
Member

Zac-HD commented Aug 17, 2022

You can of course get the native representation with pytest --tb=native, but it would indeed be good to support the more precise locations in long, short, and auto modes too 🙂

@nicoddemus nicoddemus changed the title PEP-657 enhanced error locations in Pytest tracebacks PEP-657 enhanced error locations in pytest tracebacks Aug 17, 2022
@bluetech bluetech added the status: help wanted developers would like help from experts on this topic label Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: help wanted developers would like help from experts on this topic topic: tracebacks related to displaying and handling of tracebacks type: enhancement new feature or API change, should be merged into features branch
Projects
None yet
Development

No branches or pull requests

4 participants