[Python-3000] self-contained exceptions

Phillip J. Eby pje at telecommunity.com
Mon Jan 8 18:25:43 CET 2007


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?
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>]:
And to heck with the rest of the complexity. :) For migration 
convenience, we could offer this syntax as an option in 2.x, preferably 
with the same name-clearing behavior, even though it's not needed.


More information about the Python-3000 mailing list

AltStyle によって変換されたページ (->オリジナル) /