On Feb 7, 2020, at 07:47, Anders Hovmöller <boxed@killingar.net> wrote: If the only difference is the text between the stack traces, why aren't you suggesting to change that text?
I think in the case where the exception handler code has an error in handling the exception (e.g., you try to log to a closed file), the existing text is exactly right, and the text used in the explicit chaining case would be misleading. However, Shai Berger had an interesting idea in that Django thread: treat a `raise` directly under an `except` block special. For example: except ZeroDivisionError: raise ValueError('whatever') # would produce a chaining error message except ZeroDivisionError: log(closedfile, “whatever”) # would produce an another error during handling error message except ZeroDivisionError: MyFancyError(stuff).throwme() # would produce error during handling like the log case # unless the author of throwme decides they want otherwise # in which case they just have to check and raise from I’m not sure if “special” should mean that it’s treated identical to a raise from (as Shai suggested), as that might cause backward compat issues? I haven’t thought it through. Alternatively, if we just stash a new flag somewhere that the traceback machinery can find, we could get the same behavior (or even a third distinct connecting string) without any such issues, at the cost of more complexity. There might be other problems I’m not seeing here. But it seems at least worth exploring.