[Python-3000] self-contained exceptions

Brett Cannon brett at python.org
Mon Jan 8 06:28:43 CET 2007


On 1/7/07, Collin Winter <collinw at gmail.com> 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.

Having 'e' be a tuple or list in Py3K will be rather uncommon? If you look
at PEP 352 you will notice that the __getitem__ method for BaseException is
going to be gone so the unpacking of an exception will not be something you
can normally do. If you want to add the support for unpacking when someone
subclasses BaseException and adds __getitem__ that's fine, but in the
general case it won't be used very much I suspect.
-Brett
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-3000/attachments/20070107/955c00a1/attachment.htm 


More information about the Python-3000 mailing list

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