[Python-Dev] PEP 415: Implementing PEP 409 differently (original) (raw)
Nick Coghlan ncoghlan at gmail.com
Mon Feb 27 03:15:01 CET 2012
- Previous message: [Python-Dev] PEP 415: Implementing PEP 409 differently
- Next message: [Python-Dev] PEP 415: Implementing PEP 409 differently
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Thanks for writing that up. I'd be amenable if the PEP was clearly
updated to say that raise exc from cause
would change from being
syntactic sugar for _hidden = exc; _hidden.__cause__ = cause; raise exc
(as it is now) to _hidden = exc; _hidden.__cause__ = cause; _hidden.__suppress_context__ = True; raise exc
. The patch should
then be implemented accordingly (including appropriate updates to the
language reference).
I previously didn't like this solution because I thought it would require a special case for None in the syntax expansion, but I have now realised that isn't the case (since the new flag can be set unconditionally regardless of the value assigned to cause).
Code that wants to display both cause and context can then just either set cause directly, or else later switch off the context suppression.
Cheers, Nick.
-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
- Previous message: [Python-Dev] PEP 415: Implementing PEP 409 differently
- Next message: [Python-Dev] PEP 415: Implementing PEP 409 differently
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]