-
-
Notifications
You must be signed in to change notification settings - Fork 31k
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
Typo hint message for from-imports? #91058
Comments
See for example: >>> from pygments.regexopt import regexopt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'regexopt' from 'pygments.regexopt' (/home/jean/repos/pygments/pygments/regexopt.py)
>>> from pygments.regexopt import regex_opt
>>> regexopt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'regexopt' is not defined. Did you mean: 'regex_opt'? In Python 3.10, there is a nice helpful error message suggesting |
I evaluated this, but is considerably more complex than the regular import, because one triggers an attribute error where we have the full module but in the second case we don't have the full module ready, so it requires considerable modifications. I will investigate again if there is a way that doesn't require lots of changes, but is likely that we unfortunately need to reject this improvement :( |
Pablo's reply hints that the added complexity would not be worth it. I suggest to consider closing this as rejected, unless Pablo found a less complex way :) |
Perhaps it is doable within CPython without too much added code since is something that friendly_traceback can do.
|
@aroberge You comment shows that friendly_traceback does it but unfortunately, it doesn't mention how you are proposing us to do it so we cannot evaluate the solution :( Could you add a brief sketch of how you are doing it in |
@pablogsal The relevant code starts at: Perhaps the way that the information available to friendly_traceback after an exception has been raised is not yet available to CPython at that point, but I thought I should mention this possibility. |
The problem with this approach is that if we do this every time the interpreter raises an |
Understood; most Python users (myself included) do appreciate this emphasis on speed. Those requiring better traceback analysis can use third-party packages, like friendly_traceback. |
Yeah, I think this approach is not very useful for CPython. A lot of stdlib modules try to import their C implementation first, else fall back to a Python implementation. I think we can safely close this. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: