Message364272
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. |
|
Date |
User |
Action |
Args |
2020-03-15 23:35:40 | ncoghlan | set | recipients:
+ ncoghlan, rhettinger, terry.reedy, benjamin.peterson, ethan.furman, serhiy.storchaka, Ido Michael |
2020-03-15 23:35:40 | ncoghlan | set | messageid: <1584315340.22.0.868516090351.issue39725@roundup.psfhosted.org> |
2020-03-15 23:35:40 | ncoghlan | link | issue39725 messages |
2020-03-15 23:35:39 | ncoghlan | create | |
|