[issue44026] IDLE doesn't offer "Did you mean?" for AttributeError and NameError

2021-05-04 Thread Dennis Sweeney
Dennis Sweeney added the comment: Another idea: do what test_exceptions() does: try: f() except NameError as exc: with support.captured_stderr() as err: sys.__excepthook__(*sys.exc_info()) self.assertNotIn("a1", err.getvalue())

[issue44026] IDLE doesn't offer "Did you mean?" for AttributeError and NameError

2021-05-04 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: Those are intesting options, I will think about this. I am still afraid of adding more APIs in this area as having arbitrary Python getting call in the middle of handling the exceptions it can be quite tricky: think that we are handling an exception

[issue44026] IDLE doesn't offer "Did you mean?" for AttributeError and NameError

2021-05-04 Thread Terry J. Reedy
Terry J. Reedy added the comment: I realized after posting that looking for close matching is a performance issue and does not need to be done unless the exception is going to be displayed. But it is a shame to keep such great work away from many users. What would you think of either 1.

[issue44026] IDLE doesn't offer "Did you mean?" for AttributeError and NameError

2021-05-04 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: I don't feel comfortable adding a public API to get the message either in the traceback or the exception, at least for the time being. -- ___ Python tracker

[issue44026] IDLE doesn't offer "Did you mean?" for AttributeError and NameError

2021-05-04 Thread Pablo Galindo Salgado
Pablo Galindo Salgado added the comment: > Pablo, I checked an AttributeError instance and the missing phrase is not > present This cannot be included in the AttributeError because of performance reasons. These errors will be thrown naturally all over the place without this meaning that

[issue44026] IDLE doesn't offer "Did you mean?" for AttributeError and NameError

2021-05-04 Thread Terry J. Reedy
Terry J. Reedy added the comment: (Shreyan, the fake filenames are not relevant.) By default, sys.excepthook is sys.__excepthook is . So by default IDLE runcode calls print_exception, which call cleanup_traceback for each traceback printed. This function makes two important changes to

[issue44026] IDLE doesn't offer "Did you mean?" for AttributeError and NameError

2021-05-04 Thread Shreyan Avigyan
Shreyan Avigyan added the comment: Does the test suite run succesfully? -- ___ Python tracker ___ ___ Python-bugs-list mailing

[issue44026] IDLE doesn't offer "Did you mean?" for AttributeError and NameError

2021-05-04 Thread Dennis Sweeney
Dennis Sweeney added the comment: Indeed, this change enables the feature for IDLE, though I'm not sure what it breaks. diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py index 07e9a2bf9c..319b16f311 100644 --- a/Lib/idlelib/run.py +++ b/Lib/idlelib/run.py @@ -569,7 +569,7 @@ def

[issue44026] IDLE doesn't offer "Did you mean?" for AttributeError and NameError

2021-05-04 Thread Dennis Sweeney
Dennis Sweeney added the comment: It looks like Lib/idlelib/run.py : print_exception() re-implements the traceback, rather than relying on sys.excepthook -- ___ Python tracker

[issue44026] IDLE doesn't offer "Did you mean?" for AttributeError and NameError

2021-05-04 Thread Dennis Sweeney
Dennis Sweeney added the comment: PyErr_Display() grabs the current sys.stderr and writes to that, but it looks like IDLE never gets to call PyErr_Display(). -- ___ Python tracker

[issue44026] IDLE doesn't offer "Did you mean?" for AttributeError and NameError

2021-05-04 Thread Dennis Sweeney
Dennis Sweeney added the comment: I'm not sure if this helps, but this is the relevant tree of callers: suggestions.c: _Py_Offer_Suggestions() (the expected behavior) is only referenced by pythonrun.c: print_exception(), which is only referenced by pythonrun.c: print_exception_recursive(),

[issue44026] IDLE doesn't offer "Did you mean?" for AttributeError and NameError

2021-05-04 Thread Shreyan Avigyan
Shreyan Avigyan added the comment: Python shell uses to evaluate while IDLE uses . Is that the problem? -- nosy: +shreyanavigyan ___ Python tracker ___

[issue44026] IDLE doesn't offer "Did you mean?" for AttributeError and NameError

2021-05-04 Thread Terry J. Reedy
Terry J. Reedy added the comment: I am surprised for 2 reasons. First, I have seen other improved messages in IDLE, though maybe only for syntax errors. Second, code entered through IDLE is executed by Python, 'same' in this respect as code entered through the REPL. In more detail, IDLE

[issue44026] IDLE doesn't offer "Did you mean?" for AttributeError and NameError

2021-05-03 Thread Dennis Sweeney
Change by Dennis Sweeney : -- nosy: +pablogsal ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue44026] IDLE doesn't offer "Did you mean?" for AttributeError and NameError

2021-05-03 Thread Dennis Sweeney
New submission from Dennis Sweeney : After bpo-38530, I get this in the python shell: Python 3.10.0b1 (tags/v3.10.0b1:ba42175, May 3 2021, 20:22:30) [MSC v.1928 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> class A: ... foobar = 1