Skip to content

Commit 0dab17a

Browse files
committed
Skip tarfile filter= on Python 3.10 without PEP 706 backport
1 parent 04b2fa7 commit 0dab17a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

automation_file/local/tar_ops.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
"xz": "w:xz",
2727
}
2828

29+
_TAR_FILTER_SUPPORTED = hasattr(tarfile, "data_filter")
30+
2931

3032
class TarException(FileAutomationException):
3133
"""Raised when tar creation or extraction fails."""
@@ -77,7 +79,10 @@ def extract_tar(source: str, target_dir: str) -> list[str]:
7779
with tarfile.open(str(src_path), "r:*") as archive:
7880
_verify_members(archive, dest)
7981
for member in archive.getmembers():
80-
archive.extract(member, str(dest), filter="data")
82+
if _TAR_FILTER_SUPPORTED:
83+
archive.extract(member, str(dest), filter="data")
84+
else:
85+
archive.extract(member, str(dest))
8186
extracted.append(member.name)
8287
except PathTraversalException:
8388
raise

0 commit comments

Comments
 (0)