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 ncoghlan
Recipients Ido Michael, benjamin.peterson, ethan.furman, ncoghlan, rhettinger, serhiy.storchaka, terry.reedy
Date 2020-03-15.23:35:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1584315340.22.0.868516090351.issue39725@roundup.psfhosted.org>
In-reply-to
Content
Tweaked title to be "hide" rather "lose" (all the info is theoretically still there in various places, it's just hidden by the default traceback printing machinery, and hard to extract from the exception tree).

Issue #18861 is the original report of this problem.

My concern with Serhiy's suggestion is that it would take us from merely hiding information to actually losing it.

I'm wondering if we're actually missing a piece of lower level infrastructure: a query API that reports *all* live exceptions in a thread.

For example, there might be a "sys.active_exceptions()" API that returned a list of all active exceptions.

* []: No exception active
* [exc]: Running an except/finally/__exit__ for "exc"
* [exc_inner, exc_outer]: Running an except/finally/__exit__ for "exc_inner" inside one for "exc_outer"
* etc

So in Serhiy's example, at the point where the context is suppressed, that new API would report [ValueError(), TypeError()] (with the relevant caught exception instances).

Given that extra low level API, we would gain more options for populating attributes on exceptions.

Alternatively, Serhiy's suggested approach might be sufficient, even without that new API, if we added a new __suppressed_context__ attribute to capture the original value of __context__ before it was replaced.
History
Date User Action Args
2020-03-15 23:35:40ncoghlansetrecipients: + ncoghlan, rhettinger, terry.reedy, benjamin.peterson, ethan.furman, serhiy.storchaka, Ido Michael
2020-03-15 23:35:40ncoghlansetmessageid: <1584315340.22.0.868516090351.issue39725@roundup.psfhosted.org>
2020-03-15 23:35:40ncoghlanlinkissue39725 messages
2020-03-15 23:35:39ncoghlancreate