On Feb 03, 2012, at 08:52 AM, Ethan Furman wrote:

>Not sure I'll ever use it this way, but:
>
>try:
>   try:
>     raise IndexError()
>   except:
>     raise CustomError() from None
>except CustomError as e:
>   # nevermind, let's see the whole thing after all
>   raise e from Ellipsis

In that context, I have to say that the last line, even if it were written

    raise e from ...

is certainly cute, but not very informative.  Triple-dots will be confusing
and difficult to read in documentation and code, and Ellipsis has no logical
connection to the purpose of this PEP.  So while I'm +1 on everything else in
the PEP, I'm -1 on this particular decision.

One of the alternatives states:

    Create a special exception class, __NoException__.

    Rejected as possibly confusing, possibly being mistakenly raised by users,
    and not being a truly unique value as None, True, and False are.

I think this should be revisited.  First, `__NoException__` doesn't need to be
an exception class.  Ellipsis isn't so this doesn't need to be either.  I have
no problem adding a new non-exception derived singleton to mark this.  And
while __NoException__ may be a little confusing, something like __NoCause__
reads great and can't be mistaken for a raiseable exception.

So your example would then be:

try:
   try:
     raise IndexError()
   except:
     raise CustomError() from None
except CustomError as e:
   # nevermind, let's see the whole thing after all
   raise e from __NoCause__

Cheers,
-Barry
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to