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

Provide NameError/AttributeError suggestions in traceback.py #97008

Open
ambv opened this issue Sep 22, 2022 · 1 comment
Open

Provide NameError/AttributeError suggestions in traceback.py #97008

ambv opened this issue Sep 22, 2022 · 1 comment
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@ambv
Copy link
Contributor

ambv commented Sep 22, 2022

Python 3.10 added NameError and AttributeError suggestions in raised exceptions, in the form of:

>>> dim
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'dim' is not defined. Did you mean: 'dir'?

This is implemented in Python/suggestions.c and unavailable in the pure Python implementation of traceback formatting in Lib/traceback.py. This makes the output of both different, which is problematic for tooling using traceback.py, as well as for alternative implementations of Python like PyPy and GraalPy.

Let's implement the equivalent of suggestions.c in Lib/traceback.py to bring both in line.

@ambv ambv added type-bug An unexpected behavior, bug, or error type-feature A feature request or enhancement stdlib Python modules in the Lib dir and removed type-bug An unexpected behavior, bug, or error labels Sep 22, 2022
@ambv
Copy link
Contributor Author

ambv commented Sep 22, 2022

cc @cfbolz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

1 participant