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:
committed by
gmierz2@outlook.com
parent
e8c0fe7798
commit
2d0c0faeef
@@ -3,6 +3,7 @@
|
|||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
import copy
|
import copy
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
from argparse import ArgumentParser, Namespace
|
from argparse import ArgumentParser, Namespace
|
||||||
|
|
||||||
import mozlog
|
import mozlog
|
||||||
@@ -184,13 +185,18 @@ class PerftestArgumentParser(ArgumentParser):
|
|||||||
res[key] = value
|
res[key] = value
|
||||||
return res
|
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
|
# at this point, the namespace is filled with default values
|
||||||
# defined in the args
|
# defined in the args
|
||||||
|
|
||||||
# let's parse what the user really gave us in the CLI
|
# let's parse what the user really gave us in the CLI
|
||||||
# in a new namespace
|
# in a new namespace
|
||||||
user_namespace, extras = super()._parse_known_args(arg_strings, 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()])
|
self.set_by_user = list([name for name, value in user_namespace._get_kwargs()])
|
||||||
|
|
||||||
@@ -200,8 +206,10 @@ class PerftestArgumentParser(ArgumentParser):
|
|||||||
|
|
||||||
return namespace, extras
|
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)
|
self.parse_helper(args)
|
||||||
|
if sys.version_info.minor > 11:
|
||||||
|
return super().parse_args(args, namespace, intermixed=intermixed)
|
||||||
return super().parse_args(args, namespace)
|
return super().parse_args(args, namespace)
|
||||||
|
|
||||||
def parse_known_args(self, args=None, namespace=None):
|
def parse_known_args(self, args=None, namespace=None):
|
||||||
|
|||||||
Reference in New Issue
Block a user