[Python-Dev] PEP 490: Chain exceptions at C level

Stefan Behnel stefan_ml at behnel.de
Sat Jun 20 11:00:47 CEST 2015

Victor Stinner schrieb am 20.06.2015 um 09:30:
> Are you ok to chain exceptions at C level by default?

I agree that it can be a bit non-obvious where exceptions are chained and
when they are not and my guess is that most C code simply doesn't take care
of chaining exceptions at all. If only because it was ported from Python 2
to the point that it worked in Python 3. Almost no test suite will include
dedicated tests for chained exception handling in C code, so flaws in this
area would rarely be noticed.

I'm rather for this proposal (say, +0.3) for consistency reasons, but it
will break code that was written with the assumption that exception
chaining doesn't happen for the current exception automatically, and also
code that incidentally gets it right. I don't think I have an idea of
what's more common in C code - that exception chaining is wanted, or that
the current exception is intentionally meant to be replaced by another.

And that is the crux in your proposal: you're changing the default
behaviour into its opposite. In order to do that, it should be reasonably
likely that the current standard behaviour is not intended in more than
half of the cases. I find that difficult to estimate.


More information about the Python-Dev mailing list