[Python-3000] self-contained exceptions

Collin Winter collinw at gmail.com
Mon Jan 8 18:34:54 CET 2007


On 1/8/07, Phillip J. Eby <pje at telecommunity.com> wrote:
> At 10:25 AM 1/8/2007 -0600, Collin Winter wrote:
> >On 1/8/07, Phillip J. Eby <pje at telecommunity.com> wrote:
> >>At 09:14 PM 1/7/2007 -0600, Collin Winter wrote:
> >> >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.
> >
> >Ah, good point. I'll update the patch to strip out that extra code.
>
> Hm... what happens with things like:
>
>       except Exception, x[y]:
>
> and
>
>       except Exception, x(y).z:
>
> Are these currently allowed?  Should they be allowed?  And should we clear
> them?

They are currently allowed, and they are currently being cleared.

> My inclination is to say that we should only clear in the simple local
> variable case, as anything more advanced is up to the author to sort out.
>
> Actually, I think we should probably just define the syntax in Py3K as:
>
>       except <expr> [as <name>]:
>

FWIW, I wasn't aware that things like "except T, (a, b, c):" were
possible until I started work on this patch; I thought <name> was all
you _could_ use.

Collin Winter


More information about the Python-3000 mailing list