[Python-3000] self-contained exceptions
Phillip J. Eby
pje at telecommunity.com
Mon Jan 8 07:21:27 CET 2007
At 09:14 PM 1/7/2007 -0600, Collin Winter wrote:
>On 1/4/07, Guido van Rossum <guido at python.org> wrote:
> > On 1/4/07, Phillip J. Eby <pje at telecommunity.com> wrote:
> > > How about:
> > >
> > > except ExcType, e:
> > > try:
> > > # body
> > > finally:
> > > e = None
> > > del e
> > >
> > > Then we get the best of all three worlds: a clean explanation, a clean
> > > implementation, and a pure source-to-source transformation.
> >
> > Great! We need (a) an update to PEP 3100 and (b) a patch to implement
> > this. (Once we have this we can talk about the rest of PEP 344;
> > perhaps that PEP should also target Py3k only?)
>
>I've just uploaded patch #1630248 to SF. This implements the
>transformation (including test cases for the new behavior) and patches
>all places in the stdlib that relied on the old behavior.
>
>The transformation is as Phillip outlined above, with extra logic to
>handle the case where e is a tuple or list.
In the tuple or list case, there's no need to reset the variables, because
then the traceback won't be present any more; the exception object will
have been discarded after unpacking.
More information about the Python-3000
mailing list