commit: 16790e10f1823aad3872b84db68978135c051202
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 4 18:45:45 2024 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Dec 4 19:19:31 2024 +0000
URL:
https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=16790e10
fix argument parsing with Python 3.12.8
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>
src/pkgcheck/scripts/argparse_actions.py | 8 +++++++-
src/pkgcheck/scripts/pkgcheck_scan.py | 8 +++++++-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/pkgcheck/scripts/argparse_actions.py
b/src/pkgcheck/scripts/argparse_actions.py
index 02053cf9..4507e10f 100644
--- a/src/pkgcheck/scripts/argparse_actions.py
+++ b/src/pkgcheck/scripts/argparse_actions.py
@@ -216,7 +216,13 @@ class ChecksetArgs(arghparse.CommaSeparatedNegations):
args.append(f"--checks={checks}")
keywords = ",".join(enabled_keywords | {f"-{x}" for x in
disabled_keywords})
args.append(f"--keywords={keywords}")
- parser._parse_known_args(args, namespace)
+ # Python 3.12.8 introduced obligatory intermixed arg. The same
+ # commit adds _parse_known_args2 function, so use that to determine
+ # if we need to pass that.
+ if hasattr(parser, "_parse_known_args2"):
+ parser._parse_known_args(args, namespace, intermixed=False)
+ else:
+ parser._parse_known_args(args, namespace)
class ScopeArgs(arghparse.CommaSeparatedNegations):
diff --git a/src/pkgcheck/scripts/pkgcheck_scan.py
b/src/pkgcheck/scripts/pkgcheck_scan.py
index 7c11f810..7e554aab 100644
--- a/src/pkgcheck/scripts/pkgcheck_scan.py
+++ b/src/pkgcheck/scripts/pkgcheck_scan.py
@@ -375,7 +375,13 @@ def _setup_scan(parser, namespace, args):
patch("pkgcheck.scripts.argparse_actions.ChecksetArgs.__call__",
lambda *a, **k: None),
patch("pkgcheck.scripts.argparse_actions.ExitArgs.__call__", lambda
*a, **k: None),
):
- namespace, _ = parser._parse_known_args(args, namespace)
+ # Python 3.12.8 introduced obligatory intermixed arg. The same
+ # commit adds _parse_known_args2 function, so use that to determine
+ # if we need to pass that.
+ if hasattr(parser, "_parse_known_args2"):
+ namespace, _ = parser._parse_known_args(args, namespace,
intermixed=False)
+ else:
+ namespace, _ = parser._parse_known_args(args, namespace)
# Get the current working directory for repo detection and restriction
# creation, fallback to the root dir if it's be removed out from under us.