Nick Coghlan <ncogh...@gmail.com> added the comment:

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.

----------
title: unrelated  `from None` exceptions lose prior exception information -> 
unrelated  `from None` exceptions hide prior exception information

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue39725>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to