diff --git a/audeer/core/io.py b/audeer/core/io.py index f1f03b2..564a7bd 100644 --- a/audeer/core/io.py +++ b/audeer/core/io.py @@ -5,6 +5,7 @@ import itertools import os import shutil +import sys import tarfile import typing import urllib.request @@ -369,7 +370,15 @@ def extract_archive( desc=desc, disable=disable, ): - tf.extract(member, destination, numeric_owner=True) + # In Python 3.12 the `filter` argument was introduced, + # and it will be set automatically in Python 3.14, + # see + # https://docs.python.org/3.12/library/tarfile.html#tarfile-extraction-filter + # noqa: E501 + kwargs = {"numeric_owner": True} + if sys.version_info >= (3, 12): # pragma: no cover + kwargs = kwargs | {"filter": "tar"} + tf.extract(member, destination, **kwargs) files = [m.name for m in members] else: raise RuntimeError(