Another Python regression

This commit is contained in:
Waf Project 2024-07-13 23:06:31 +08:00
parent c816802d87
commit 8971304c36
4 changed files with 17 additions and 4 deletions

View File

@ -40,7 +40,10 @@ else:
with open(tf, 'wb') as f:
f.write(pkgdata)
with tarfile.open(tf) as f:
f.extractall(tmp)
if hasattr(tarfile, 'data_filter'):
f.extractall(tmp, filter='data')
else:
f.extractall(tmp)
os.remove(tf)
os.rename(tmp, dest)
finally:

View File

@ -100,7 +100,11 @@ def unpack_wafdir(dir, src):
err("Waf cannot be unpacked, check that bzip2 support is present")
try:
for x in t: t.extract(x)
for x in t:
if hasattr(tarfile, 'data_filter'):
t.extract(x, filter='data')
else:
t.extract(x)
finally:
t.close()

View File

@ -561,7 +561,10 @@ class DistCheck(Dist):
with tarfile.open(self.get_arch_name()) as t:
for x in t:
t.extract(x)
if hasattr(tarfile, 'data_filter'):
t.extract(x, filter='data')
else:
t.extract(x)
instdir = tempfile.mkdtemp('.inst', self.get_base_name())
cmd = self.make_distcheck_cmd(instdir)

View File

@ -363,7 +363,10 @@ class package_reader(Context.Context):
with tarfile.open(tmpfile) as f:
temp = tempfile.mkdtemp(dir=pkgdir)
try:
f.extractall(temp)
if hasattr(tarfile, 'data_filter'):
f.extractall(temp, filter='data')
else:
f.extractall(temp)
os.rename(temp, os.path.join(pkgdir, subdir))
finally:
try: