[3.9] bpo-39039: tarfile raises descriptive exception from zlib.error (GH-27766) by ambv · Pull Request #28614 · python/cpython
Conversation
- during tarfile parsing, a zlib error indicates invalid data
- tarfile.open now raises a descriptive exception from the zlib error
- this makes it clear to the user that they may be trying to open a
corrupted tar file.
(cherry picked from commit b6fe857)
Note: since BPO-39717 wasn't backported to 3.9, this backport PR doesn't use from None in the new raise statement either.
Co-authored-by: Jack DeVries 58614260+jdevries3133@users.noreply.github.com
…pythonGH-27766) * during tarfile parsing, a zlib error indicates invalid data * tarfile.open now raises a descriptive exception from the zlib error * this makes it clear to the user that they may be trying to open a corrupted tar file. (cherry picked from commit b6fe857) Co-authored-by: Jack DeVries <58614260+jdevries3133@users.noreply.github.com>
| try: | ||
| import zlib | ||
| if isinstance(e, zlib.error): | ||
| raise ReadError(f'zlib error: {e}') |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this have from e at the end?
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please read the description of the backport.
ambv
deleted the
backport-b6fe857-3.9
branch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters