Terry J. Reedy <tjre...@udel.edu> added the comment:
Pablo, unless you are suggesting rewriting IDLE's custom exception handing in C, I don't see how making it a single function would be an improvement. As long as it is Python code, the problem is accessing the message supplement. After reading your comment, I agree that injecting Python code into the C exception handling is a bad idea. It also, I see now, not needed run.print_exception first calls traceback.extract_tb (line 238). The doc says " It is useful for alternate formatting of stack traces", which IDLE does. print_exception next calls the undocumented traceback.print_list, which is format_list + print*. Finally, print_exception calls traceback.format_exception_only (line 2440), which returns a list of lines that is immediately printed. So all IDLE needs is for format_exception_only to include the extra lines, either by default or by option. But it just calls TracebackException.format_exception)only, which call a private Python-coded function, which can only add the lines if accessible from Python-code. Dennis cleverly pointed out that such access is available, even if awkwardly, by capturing the standard excepthook outout and keeping only the missing part. (test.support.captured_stderr just wraps io.StringIO as a context manager. IDLE can borrow and edits its code.) Dennis, would you like to prepare a PR that follows the format_exception_only call with something like if isinstance(typ, (AttributeError, NameError)): lines.extend(extract_extra_message(<args>)) and a definition of the new function? (and a new test)? Or perhaps better, replace format_exception_only with a function that gets all lines at once. Pablo, do any other exception types have such omitted help info? Do you have plans for any more? ---------- title: IDLE doesn't offer "Did you mean?" for AttributeError and NameError -> IDLE: print "Did you mean?" for AttributeError and NameError _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue44026> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com