Skip to content

[3.9] bpo-39039: tarfile raises descriptive exception from zlib.error (GH-27766) #28614

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 29, 2021

Conversation

ambv
Copy link
Contributor

@ambv ambv commented Sep 29, 2021

  • 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

https://bugs.python.org/issue39039

…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}')
Copy link
Contributor

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?

Copy link
Contributor Author

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 ambv merged commit 7bff4d3 into python:3.9 Sep 29, 2021
@ambv ambv deleted the backport-b6fe857-3.9 branch September 29, 2021 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants