Skip to content

Commit

Permalink
python: suppress warnings from PEP 706 (trivial)
Browse files Browse the repository at this point in the history
Suppress warnings raised from python 3.12 and later by PEP 706 – Filter for tarfile.extractall.

In Python 3.12, a DeprecationWarning about tarfile filtering by default in Python 3.14

    DeprecationWarning: Python 3.14 will, by default, filter extracted
    tar archives and reject files or modify their metadata.
    Use the filter argument to control this behavior.

To enable this for simple cases, the built-in filters will have string
names; e.g. users can pass filter='data' instead of a specific function
that deals with TarInfo objects.

Read more: https://peps.python.org/pep-0706/
  • Loading branch information
Chilledheart committed Oct 17, 2024
1 parent 4a397da commit 21269b2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion scripts/download-clang-prebuilt-binaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ def download_url(url, tarball):
def extract_tarfile(tar):
print('Extracting %s' % tar)
with tarfile.open(tar) as package_tar:
package_tar.extractall()
if sys.version_info >= (3, 12):
package_tar.extractall(filter='tar')
else:
package_tar.extractall()

def mkdir_p(path):
try:
Expand Down
5 changes: 4 additions & 1 deletion scripts/install-sysroot-freebsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ def extract_tarfile(tar, sysroot=".", filters=[]):
filtered_members.append(member)
if not filtered_members:
return
package_tar.extractall(sysroot, filtered_members)
if sys.version_info >= (3, 12):
package_tar.extractall(sysroot, filtered_members, filter='tar')
else:
package_tar.extractall(sysroot, filtered_members)


def GetSha256(filename):
Expand Down
5 changes: 4 additions & 1 deletion scripts/install-sysroot.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ def GetSha1(filename):
def extract_tarfile(tar, sysroot):
print('Extracting %s' % tar)
with tarfile.open(tar) as package_tar:
package_tar.extractall(sysroot)
if sys.version_info >= (3, 12):
package_tar.extractall(sysroot, filter='tar')
else:
package_tar.extractall(sysroot)
def main(args):
parser = optparse.OptionParser('usage: %prog [OPTIONS]', description=__doc__)
parser.add_option('--arch',
Expand Down

0 comments on commit 21269b2

Please sign in to comment.