This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author terry.reedy
Recipients Dennis Sweeney, pablogsal, shreyanavigyan, terry.reedy
Date 2021-05-04.10:52:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1620125539.51.0.695137292922.issue44026@roundup.psfhosted.org>
In-reply-to
Content
(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.
History
Date User Action Args
2021-05-04 10:52:19terry.reedysetrecipients: + terry.reedy, pablogsal, Dennis Sweeney, shreyanavigyan
2021-05-04 10:52:19terry.reedysetmessageid: <1620125539.51.0.695137292922.issue44026@roundup.psfhosted.org>
2021-05-04 10:52:19terry.reedylinkissue44026 messages
2021-05-04 10:52:19terry.reedycreate