On Sat, Jan 28, 2012 at 10:33 AM, Ethan Furman <et...@stoneleaf.us> wrote:
> Because at this point it is possible to do:
>
>    raise ValueError from NameError
>
> outside a try block.  I don't see it as incredibly useful, but I don't know
> that it's worth making it illegal.
>
> So the question is:
>
>  - should 'raise ... from ...' be legal outside a try block?
>
>  - should 'raise ... from None' be legal outside a try block?

Given that it would be quite a bit of work to make it illegal, my
preference is to leave it alone.

I believe that means there's only one open question. Should "raise ex
from None" be syntactic sugar for:

1. clearing the current thread's exception state (as I believe Ethan's
patch currently does), thus meaning that __context__ and __cause__
both end up being None
2. setting __cause__ to None (so that __context__ still gets set
normally, as it is now when __cause__ is set to a specific exception),
and having __cause__ default to a *new* sentinel object that indicates
"use __context__"

I've already stated my own preference in favour of 2 - that approach
means developers that think about it can explicitly change exception
types such that the context isn't displayed by default, but
application and framework developers remain free to insert their own
exception handlers that *always* report the full exception stack.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncogh...@gmail.com   |   Brisbane, Australia
_______________________________________________
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