[issue44026] IDLE: print "Did you mean?" for AttributeError and NameError

Terry J. Reedy report at bugs.python.org
Fri May 7 21:00:05 EDT 2021


Terry J. Reedy <tjreedy at udel.edu> added the comment:

Merged to 3.11.0a0 first, bot forget to post it.

Dennis, thank you for the analysis and then the suggestion as to how to access the not directly accessible.  It would likely have been awhile before I stumbled from 'cannot' to 'can with workaround'.  Feel free to add ideas on other IDLE issues.

Thanks EP for making the fix work even with chained exceptions *and* for providing tests.  I redid half the lines, but core test logic was correct and remains.  In .0b1+ repository (and future .0b2 release) IDLE:

>>> try: abc
... except NameError: f"{complex.reel(1+1j)} errors occurred!"
... 
Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    try: abc
NameError: name 'abc' is not defined. Did you mean: 'abs'?

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<pyshell#2>", line 2, in <module>
    except NameError: f"{complex.reel(1+1j)} errors occurred!"
AttributeError: type object 'complex' has no attribute 'reel'. Did you mean: 'real'?

And thank you Pablo for making exception messages more helpful.

----------
stage: patch review -> 

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44026>
_______________________________________


More information about the Python-bugs-list mailing list