[issue39717] Fix exception causes in tarfile module
Vedran Čačić
report at bugs.python.org
Sun Feb 23 11:24:28 EST 2020
Vedran Čačić <vedgar at gmail.com> added the comment:
Oh yes, this has bugged me often. Please fix it somehow.
Yes, using "from None" is probably the wrong way to go. Often we need more info in tracebacks, not less. But the "During handling" message is very misleading. Same as Ethan, many times I interpreted it as "something went wrong in the handler" when in fact the handler was doing exactly what it was supposed to do.
except WhateverException as e:
raise CustomException from e
might be too much to write every time, and while I understand that we cannot simply redefine `raise` under `except` to do that implicitly, maybe there is some middle solution. On Python-ideas, recently I saw an idea
except WhateverException:
raise as CustomException
which I like a lot, but I don't know how hard it is to implement.
---
If everything above seems like too much, at least we should consider changing the wording of the message. If it said
+"In the handler of the above exception, another exception was raised:"
-"During handling of the above exception, another exception occurred:"
I'd be much happier. And it would more often suggest the right thing.
----------
nosy: +veky
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39717>
_______________________________________
More information about the Python-bugs-list
mailing list