On Fri, Feb 07, 2020 at 10:38:42PM +0200, Ram Rachum wrote:
As far as I know, the `raise foo from bar` syntax, and the distinction between the two exception-chaining messages, didn't really catch on. I know about them, like them and use them, but most Python developers and open-source packages don't.
My point is that so far, its adoption was a failure.
Failure judged according to what standard? If a feature isn't used a lot, does that make it a failure?
Personally, I use "from None" quite a lot, so to me that's a rather big success.
If we have any hopes that its adoption will be a success, we should think, what is our plan for its success? Here are a few options:
You missed the most important:
Do nothing. Accept that "raise from error" offers little advantage over plain old "raise", and if the majority of people can't be bothered using it, don't stress over the microscopic difference in meaning between the default message "During handling of the above exception" and the "above exception was the direct cause..." message you get from explicitly setting the cause with "from error".
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.
If you disagree and want to chain your exceptions, please go right ahead doing what you are doing.