Skip to content

Commit 512fc79

Browse files
committed
Don't pass in hte filter argument to tar.extractall on old Python versions
Signed-off-by: Bernát Gábor <[email protected]>
1 parent c836ab2 commit 512fc79

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ repos:
2525
- repo: https://github.com/astral-sh/ruff-pre-commit
2626
rev: "v0.12.4"
2727
hooks:
28-
- id: ruff-format
29-
- id: ruff
28+
- id: ruff-check
3029
args: ["--fix", "--unsafe-fixes", "--exit-non-zero-on-fix"]
30+
- id: ruff-format
3131
- repo: https://github.com/asottile/blacken-docs
3232
rev: 1.19.1
3333
hooks:

docs/changelog/3568.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Don't pass in the filter argument to tar.extractall on old Python versions - by :user:`gaborbernat`.

src/tox/tox_env/python/virtual_env/package/cmd_builder.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,16 @@ def extract_install_info(self, for_env: EnvConfigSet, path: Path) -> list[Packag
108108
if not work_dir.exists(): # pragma: no branch
109109
work_dir.mkdir()
110110
with tarfile.open(str(path), "r:gz") as tar:
111-
tar.extractall( # noqa: S202
112-
path=str(work_dir),
113-
filter=tarfile.data_filter
114-
if sys.version_info >= (3, 11, 4)
111+
kwargs = {}
112+
if (
113+
sys.version_info >= (3, 11, 4)
115114
or (3, 10, 12) <= sys.version_info < (3, 11)
116115
or (3, 9, 17) <= sys.version_info < (3, 10)
117-
else None,
116+
) is not None:
117+
kwargs["filter"] = tarfile.data_filter
118+
tar.extractall( # noqa: S202
119+
path=str(work_dir),
120+
**kwargs, # type: ignore[arg-type]
118121
)
119122
# the register run env is guaranteed to be called before this
120123
assert self._sdist_meta_tox_env is not None # noqa: S101

0 commit comments

Comments
 (0)