On Fri, 7 Feb 2020 at 23:14, Steven D'Aprano email@example.com wrote:
YMMV and this is just my opinion, but personally I think that exception chaining is rarely useful even at the best of times. For me, the only time I care about "raise from" is to suppress exception chaining by setting the cause to None.
Oddly, I had an issue this week where exception chaining would have been ideal. However, it was on a codebase where I needed to support Python 2, so I couldn't use it. I went with a slightly less optimal solution that worked on Python 2. The main difference was that there is a little more clutter in the Python 3 error message, but that's not a big deal because so few people need the full traceback anyway ;-) If I had been on a Python 3 only codebase, I would have used exception chaining quite happily and naturally. Although I would *not* have been worried about the difference between the "during" vs "direct cause" wording.
So I'd be hesitant about calling exception chaining a failure (like the OP, not Steven, did) for a while yet. And even then, I would't call it a failure, just a relatively niche feature that is helpful in some uncommon cases.
And I'm definitely -1 on the proposal here to add an *extra* way to do exception chaining that adds nothing beyond a slightly abbreviated form of "raise from".