Patrick Westerhoff <patrickwesterh...@gmail.com> added the comment:

I have to agree with Georg on that. I think it would make more sense to 
introduce some internal flag/variable that keeps track of if the cause was 
explicitely set. So if cause was set (i.e. `from X` syntax is used), then 
always display it in favor of the context – except that a None-cause causes 
nothing to display.

Regardless of that I’m actually not sure if just changing the way the cause is 
displayed is a correct way to handle the context. If I explicitely raise an 
exception in an except-handler, I usually don’t expect that new exception to 
get the previous exception attached to. In the original example, I want to 
completely replace the “context” by a new exception without implicitely keeping 
over the original exception.

So even if using `from None` will prevent the context from being displayed (as 
the explicitely set cause will override it), the `__context__` will probably 
still be set by the `raise` statement, and I think that shouldn’t happen. Hence 
the `raise X instead` or `raise as X` idea that simply does not set the context 
but “destroys” it.

----------

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

Reply via email to