[Python-3000] Pre-peps on raise and except changes (was: Warning for 2.6 and greater)

Collin Winter collinw at gmail.com
Wed Jan 24 22:22:17 CET 2007


On 1/23/07, Giovanni Bajo <rasky at develer.com> wrote:
> On 22/01/2007 23.45, Collin Winter wrote:
>
> > target, thus eliminating the reference cycle. The source-to-source
> > translation, as suggested by Phillip J. Eby [#except-translation]_ is
> > ::
> >
> >     try:
> >         ...
> >     except E as N:
> >         ...
> >     ...
> >
> > is translated to ::
> >
> >     try:
> >         ...
> >     except E as N:
> >         ...
> >         N = None
> >         del N
> >     ...
> >
>
> The mail you link (which matched my recollection of the thread) has an
> additional try/finally suite in the except block translation:
>
>     except ExcType, e:
>             try:
>                 # body
>             finally:
>                 e = None
>                 del e
>
> which is missing in the PEP. I think you should probably explain why the
> try/finally is not needed (if it really is not).

The try/finally is indeed needed; I just screwed up when copying it
out for the PEP : )

> Also, the second code snippet should probably use the "except E, N" form (no
> "as") to make more clear that you're speaking of the Python 2.x equivalent of
> the 3.x form.

Thanks! I've changed the "as" to "," and included a note that the
second code sample is Python 2.

Collin WInter


More information about the Python-3000 mailing list