aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Farsi <lucafarsi@google.com>2023-07-18 10:38:20 -0700
committerLuca Farsi <lucafarsi@google.com>2023-08-02 14:23:50 -0700
commit916b5cd78488cf9deb09f58cea6ed3557134c1ea (patch)
tree771e162949b223db09e3cb0304f5817c301596cb
parentefaca93f3922cfd97d42e95d8eb9025a01b5e243 (diff)
downloadminijail-916b5cd78488cf9deb09f58cea6ed3557134c1ea.tar.gz
UPSTREAM: Fix Python deprecation warnings
Sampling from a set is deprecated as of Python 3.9. Replace those calls with random.choices calls and convert the sets to lists to eliminate this warning. BUG=b:263326760 TEST=presubmit Change-Id: I338da56a726bfdee6b98a82cdd8a6d462b5745a3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minijail/+/4694554 Reviewed-by: Mike Frysinger <vapier@chromium.org> Commit-Queue: Luca Farsi <lucafarsi@google.com> Tested-by: Luca Farsi <lucafarsi@google.com>
-rwxr-xr-xtools/compiler_unittest.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/tools/compiler_unittest.py b/tools/compiler_unittest.py
index b1592d2..19ca72f 100755
--- a/tools/compiler_unittest.py
+++ b/tools/compiler_unittest.py
@@ -404,7 +404,8 @@ class CompileFileTests(unittest.TestCase):
num_entries = 64 * (i + 1) // iterations
syscalls = dict(
zip(
- random.sample(self.arch.syscalls.keys(), num_entries),
+ random.sample(
+ list(self.arch.syscalls.keys()), num_entries),
(random.randint(1, 1024) for _ in range(num_entries)),
))
@@ -479,7 +480,8 @@ class CompileFileTests(unittest.TestCase):
# codegen layer will coalesce filters that compile to the same
# instructions.
policy_contents = []
- for name in random.sample(self.arch.syscalls.keys(), num_entries):
+ for name in random.sample(
+ list(self.arch.syscalls.keys()), num_entries):
values = random.sample(range(1024), num_entries)
syscalls[name] = values
policy_contents.append(