From 751154514a5f2b5a5c49793256d937c1e8741de5 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 14 Mar 2025 14:21:47 +0100 Subject: [PATCH] [FIX] runbot_merge: tarfile deprecation warning Starting in 3.12 `TarFile.extact(all)` can take a `filter` parameter which alters the behaviour of the extractor as it relates to the application of tar metadata. Not passing this parameter is deprecated unless the also new `TarFile.extraction_filter` attribute is set. Now there are a few wrinkles here: 1. Both parameter and attributes were added in older patch releases e.g. 3.9.17 and 3.10.12 and 3.11.4. 2. The attribute form will *not* resolve string filters, it needs the callables. As such just to be on the safe side of things set the attribute using a `getattr`, in releases with the feature it will be set to a proper value (the future default which ignores most or all metadata from the archive), and in releases without it just sets the attribute to `None` which should do no harm. --- runbot_merge/models/patcher.py | 1 + 1 file changed, 1 insertion(+) diff --git a/runbot_merge/models/patcher.py b/runbot_merge/models/patcher.py index 33218147..c5d272d7 100644 --- a/runbot_merge/models/patcher.py +++ b/runbot_merge/models/patcher.py @@ -403,6 +403,7 @@ class Patch(models.Model): if read: out = stack.enter_context(archiver.archive(parent, *read)) tf = stack.enter_context(tarfile.open(fileobj=out.stdout, mode='r|')) + tf.extraction_filter = getattr(tarfile, 'data_filter', None) tf.extractall(tmpdir) patch = subprocess.run( ['patch', f'-p{prefix}', '--directory', tmpdir, '--verbose'],