From 277ed4ace0c62bba5bca4a337cec70ff2e9d4ca6 Mon Sep 17 00:00:00 2001 From: David Hotham Date: Sat, 11 Nov 2023 15:13:21 +0000 Subject: [PATCH] avoid broken tarfile datafilter --- src/poetry/utils/helpers.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/poetry/utils/helpers.py b/src/poetry/utils/helpers.py index ad74353031d..5c312a6b6a9 100644 --- a/src/poetry/utils/helpers.py +++ b/src/poetry/utils/helpers.py @@ -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)