homepage

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 ethan.furman
Recipients benjamin.peterson, ethan.furman, ncoghlan, rhettinger, serhiy.storchaka
Date 2020年02月23日.18:24:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1582482287.43.0.847790886088.issue39725@roundup.psfhosted.org>
In-reply-to
Content
I think the way forward is going to be a recursive walk back to the first exception, and if __suppress_context__ is true for any exception then only the previous exception is omitted.
For example, the above example had the following chain:
Exception __context__ __cause__ __suppress_context__
--------- ----------- --------- --------------------
TypeError: None None False
KeyError: TypeError None False
KeyError: KeyError None True
When walking the stack to decide which items get printed, the final KeyError is printed (obviously, as it's the last one), but because its __suppress_context__ is True then the immediately preceding exception, the first KeyError, is skipped; however, the first KeyError's __suppress_context__ is False, so we do print its __context__, which is the TypeError. Giving us a traceback similar to:
---------------------------------------------------------------------
Traceback (most recent call last):
TypeError: str expected, not type
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
KeyError: 'NEW_VARIABLE'
---------------------------------------------------------------------
Which is entirely correct.
In cases where NewException has it's __cause__ set, we should print that as normal, then keep following the NewException.__context__ chain (with some kind of verbage or visual indicator between the __context__ and the __cause__).
History
Date User Action Args
2020年02月23日 18:24:47ethan.furmansetrecipients: + ethan.furman, rhettinger, ncoghlan, benjamin.peterson, serhiy.storchaka
2020年02月23日 18:24:47ethan.furmansetmessageid: <1582482287.43.0.847790886088.issue39725@roundup.psfhosted.org>
2020年02月23日 18:24:47ethan.furmanlinkissue39725 messages
2020年02月23日 18:24:47ethan.furmancreate

AltStyle によって変換されたページ (->オリジナル) /