[Python-3000] Transition to Python 3's raise syntax
Phillip J. Eby
pje at telecommunity.com
Sat Feb 24 23:23:53 CET 2007
At 03:27 PM 2/24/2007 -0600, Collin Winter wrote:
>Are "new-style" except clauses the ones spelled "except E as NAME" while
>"old-style" ones are spelled "except E, NAME"?
Yes.
>What happens in this case:
>
>e = Exception()
>e.__traceback__ = T1
>raise Exception, e, T2
>
>Which traceback takes precedence? My preference would be to raise an
>exception in this case.
Hm. How would you get that case in normal code? I guess if you had a
new-style except: that then used a 3-argument raise, you could end up with
that. I'm not sure if that's really a problem though.
In 2.6, we'll still be using the old exception machinery, so the raise will
"do the right thing", it's just that the exception instance will have a
redundant __traceback__.
I guess, if anything, my inclination would be to have the three-argument
"raise" delete e.__traceback__. T2 will get put on it if it's caught by a
new-style except: clause.
More information about the Python-3000
mailing list