Missing something on exception handling in Python 3
Steven D'Aprano
steve at pearwood.info
Tue Aug 27 05:22:42 EDT 2013
On Tue, 27 Aug 2013 00:00:36 -0500, Skip Montanaro wrote:
> I found this question/answer on Stack Overflow:
>
> http://stackoverflow.com/questions/15123137
>
> but after fiddling around with it, I can't find a solution that works
> for Python 3.2 and 3.3, let alone 2.x. In 3.2, exceptions have both
> __cause__ and __context__ attributes. I tried setting both to None (in
> 3.2), but I still get the full double traceback:
Yes, "raise from None" only works in Python 3.3.
My way of dealing with this is to use "raise from None" and just accept
that 3.1 and 3.2 users will see double tracebacks :-(
All the more reason to encourage people to go straight to 3.3 or better
and skip 3.1 and 3.2 :-)
--
Steven
More information about the Python-list
mailing list