Ethan Furman <et...@stoneleaf.us> added the comment: > 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. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue6210> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com