Bug 1966090 - Pass intermixed argument to _parse_known_args on python 3.12+. r=perftest-reviewers,afinder

This patch fixes an issue on mozperftest when running it with python 3.12+. It relates to a new parameter that has been added in python 3.13, and that does not exist in earlier versions (hence the version check).

Differential Revision: https://phabricator.services.mozilla.com/D249070
This commit is contained in:
Greg Mierzwinski
2025-05-22 00:17:11 +00:00
committed by gmierz2@outlook.com
parent e8c0fe7798
commit 2d0c0faeef

View File

@@ -3,6 +3,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
import copy
import os
import sys
from argparse import ArgumentParser, Namespace
import mozlog
@@ -184,12 +185,17 @@ class PerftestArgumentParser(ArgumentParser):
res[key] = value
return res
def _parse_known_args(self, arg_strings, namespace):
def _parse_known_args(self, arg_strings, namespace, intermixed=False):
# at this point, the namespace is filled with default values
# defined in the args
# let's parse what the user really gave us in the CLI
# in a new namespace
if sys.version_info.minor > 11:
user_namespace, extras = super()._parse_known_args(
arg_strings, Namespace(), intermixed=intermixed
)
else:
user_namespace, extras = super()._parse_known_args(arg_strings, Namespace())
self.set_by_user = list([name for name, value in user_namespace._get_kwargs()])
@@ -200,8 +206,10 @@ class PerftestArgumentParser(ArgumentParser):
return namespace, extras
def parse_args(self, args=None, namespace=None):
def parse_args(self, args=None, namespace=None, intermixed=False):
self.parse_helper(args)
if sys.version_info.minor > 11:
return super().parse_args(args, namespace, intermixed=intermixed)
return super().parse_args(args, namespace)
def parse_known_args(self, args=None, namespace=None):