[issue39717] Fix exception causes in tarfile module

Ethan Furman report at bugs.python.org
Fri Feb 21 21:02:36 EST 2020


Ethan Furman <ethan at stoneleaf.us> added the comment:

I know we are not in the habit of making large-scale changes to take advantage of new features and enhancements, but I think this may be one of the few exceptions to the rule, and it has to do with what the text between the two tracebacks means:

-----
"During handling of the above exception, another exception occurred:"

-> there is a bug in the exception handler.
-----

-----
"The above exception was the direct cause of the following exception:"

-> the first error is the cause and the second error is what we want the user to pay attention to.
-----

Whether or not the stdlib is buggy is a pretty big distinction.

If this is a change worth making the follow-on question is should we be raising from the previous exception, or from None?  How much value is the previous exception adding?

In cases where the new exception contains the text of the old one I think `from None` should be preferred; in cases where import errors get translated into CompressionErrors those import errors are sometimes useful and sometimes just noise -- perhaps including `str(e)` in the new exception is the best way there as well.

I'll need to do some research before I decide.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39717>
_______________________________________


More information about the Python-bugs-list mailing list