gh-116871: Improve name suggestions in tracebacks#116930
gh-116871: Improve name suggestions in tracebacks#116930serhiy-storchaka merged 2 commits intopython:mainfrom
Conversation
Only include underscored names in name suggestions for AttributeError and ImportError if the original name was underscored.
Lib/traceback.py
Outdated
| obj = exc_value.obj | ||
| try: | ||
| d = dir(obj) | ||
| if wrong_name[:1] != '_': |
There was a problem hiding this comment.
I guess you're using [:1] instead of [0] to handle empty strings. But there are no tests for this.
There was a problem hiding this comment.
It seems difficult to create tests for this with the current code.
If write wrong_name[0], an IndexError raised for empty wrong_name will be caught by except Exception. If write wrong_name[:1], then any non-empty names will be filtered out in the code below as too different from empty string. In any case the result is the same -- no suggestions.
|
Please take a look at the discussion before merging this. I think |
Only include underscored names in name suggestions for AttributeError and ImportError if the original name was underscored.