Terry J. Reedy <[email protected]> added the comment:
(Shreyan, the fake filenames are not relevant.)
By default, sys.excepthook is sys.__excepthook is <built-in function
excepthook>. So by default IDLE runcode calls print_exception, which call
cleanup_traceback for each traceback printed. This function makes two
important changes to the traceback.
First, it removes traceback lines that are not present when running in the
C-coded REPL, because IDLE does some functions with Python code. The result is
that IDLE tracebacks nearly always equal REPL tracebacks.
Second, for Shell code, IDLE add cached code lines. Compare
>>> a = b
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'b' is not defined
to
>>> a = b
Traceback (most recent call last):
File "<pyshell#9>", line 1, in <module>
a = b
NameError: name 'b' is not defined
>>>
We are not going to stop using print_exception. Note that it is normal for
IDEs to modify tracebacks.
The 'is' is false when user change excepthook. The false branch was recently
added to run user excepthooks.
Pablo, I checked an AttributeError instance and the missing phrase is not
present. Why is it hidden from Python code. Why not add the rest of the
message to the message? Or at least add it to the tuple or an attribute. Or
add a .get_suggestion method to exception objects, like .with_traceback.
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue44026>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com