Skip to content

Commit

Permalink
avoid broken tarfile datafilter (python-poetry#8649)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimbleby authored and MrGreenTea committed Dec 18, 2023
1 parent faa58ee commit ad0d62c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/poetry/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,14 @@ def extractall(source: Path, dest: Path, zip: bool) -> None:
with zipfile.ZipFile(source) as archive:
archive.extractall(dest)
else:
# These versions of python shipped with a broken tarfile data_filter, per
# https://github.com/python/cpython/issues/107845.
broken_tarfile_filter = {(3, 8, 17), (3, 9, 17), (3, 10, 12), (3, 11, 4)}
with tarfile.open(source) as archive:
if hasattr(tarfile, "data_filter"):
if (
hasattr(tarfile, "data_filter")
and sys.version_info[:3] not in broken_tarfile_filter
):
archive.extractall(dest, filter="data")
else:
archive.extractall(dest)

0 comments on commit ad0d62c

Please sign in to comment.