<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sun, Jul 6, 2014 at 9:16 AM, Yuras Shumovich <span dir="ltr"><<a href="mailto:shumovichy@gmail.com" target="_blank">shumovichy@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Sun, 2014-07-06 at 08:37 -0500, Mike Meyer wrote:<br>
> You left off what I think is the best behavior, from Python 3:<br>
><br>
> 4) Throw the exception for the release action, chaining the original<br>
> exception to it. The default exception handler reports the them both.<br>
<br>
You mean the "__context__" attribute of the exception? Java also allows<br>
one to get the suppressed exception via "Throwable.getSuppressed"<br>
method. But python3 suppresses the original exception, while java does<br>
the opposite, so I'm ok to count it as a separate option (#4). Thanks.<br>
<br>
><br>
> > I prefer #2 because suppressing exception is a really bad idea. What is<br>
> > your choice?<br>
><br>
> #4.<br>
<br>
Is it common for python3 code to be prepared to handle __context__? I<br>
guess most developers just ignore it. So probably #1 is better?<br></blockquote><div><br></div><div>There are two types of exception handles in most Python applications. Ones that handle specific exceptions should catch as few exceptions as possible. These are narrowed to include as little code as possible, and only catch the exceptions they know how to deal with. They normally won't deal with __context__ unless they expect to catch such exceptions.</div>

<div><br></div><div>The other type is a catchall handler that usually tries to report the exception and return the application to a known state. It should handle __context__.</div>
<div><br></div><div>Personally, I think that #2 is a really bad option, because it makes it impossible to properly write exception handlers of the second type. While I understand the urge - my usual such handler for long-running programs is to exec itself to create a clean instance -  you should still make that option available to the programmer.</div>
</div></div></div>