This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ethan.furman
Recipients aronacher, catalin.iacob, draghuram, eric.araujo, ethan.furman, ezio.melotti, mrabarnett, ncoghlan, pitrou, poke, rhettinger, steven.daprano
Date 2012-01-27.03:27:34
SpamBayes Score 3.88578e-16
Marked as misclassified No
Message-id <4F2219B4.50406@stoneleaf.us>
In-reply-to <1327629303.27.0.324384792427.issue6210@psf.upfronthosting.co.za>
Content
> 1. Any syntax change requires a PEP (and, IMO, any such PEP for this issue should get rejected: I don't consider this an important enough feature to deserve dedicated syntax. Others disagree, which is one of the reasons why a PEP is needed. The other, more important, reason is to ensure the new syntax is spec'ed out clearly and incorporated into the language reference for the benefit of other implementations in the event that it *does* get approved)

I'm not sure why this would be a syntax change.  We can already do

try:
     1/0
except ZeroDivisionError:
     raise ValueError() from MathError()

to explicitly set the __cause__ and ignore the previous context.  The 
only difference would allowing 'None' to mean 'no cause, discard 
previous context'.

> 2. A change that *doesn't* need a PEP is to just adjust the implicit exception chaining such that __context__ doesn't get set automatically if it has already been set explicitly (it turns out handling this situation was an open question in PEP 3134, not a specificied behaviour). That way, this task can be handled using a utility function:
> 
>     def no_context(new_exc):
>         new_exc.__context__ = None
>         return new_exc
> 
>     def doXY ():
>         # ...
>         try:
>             page = urlopen( someRequest )
>         except urllib.error.URLError as e:
>             raise no_context(MyError( 'while doing XY', e ))

This seems like a lot more work than just allowing None to mean none.
History
Date User Action Args
2012-01-27 03:27:34ethan.furmansetrecipients: + ethan.furman, rhettinger, ncoghlan, pitrou, draghuram, aronacher, ezio.melotti, eric.araujo, mrabarnett, steven.daprano, poke, catalin.iacob
2012-01-27 03:27:34ethan.furmanlinkissue6210 messages
2012-01-27 03:27:34ethan.furmancreate