summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKai Kang <kai.kang@windriver.com>2025-03-11 16:57:56 +0800
committerKhem Raj <raj.khem@gmail.com>2025-03-11 19:34:55 -0700
commit5a2dcee4acba15dd7f871e277e838aa2531db14e (patch)
treead1dbc56ab75dc4580b0f07030e1123c5400ba33
parent59b904920b49a0f583039e11ce1c5b190e116c07 (diff)
downloadmeta-openembedded-5a2dcee4acba15dd7f871e277e838aa2531db14e.tar.gz
python3-pykickstart: fix options parse error
Backport a patch for python3-pykickstart to fix option parse error: File "/usr/lib64/python3.12/site-packages/pykickstart/options.py", line 185, in _parse_optional option = action.option_strings[0] ^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'tuple' object has no attribute 'option_strings' Signed-off-by: Kai Kang <kai.kang@windriver.com> Signed-off-by: Khem Raj <raj.khem@gmail.com>
-rw-r--r--meta-python/recipes-extended/python-pykickstart/files/0005-options-adjust-to-behavior-change-in-upstream-_parse.patch71
-rw-r--r--meta-python/recipes-extended/python-pykickstart/python3-pykickstart_3.48.bb1
2 files changed, 72 insertions, 0 deletions
diff --git a/meta-python/recipes-extended/python-pykickstart/files/0005-options-adjust-to-behavior-change-in-upstream-_parse.patch b/meta-python/recipes-extended/python-pykickstart/files/0005-options-adjust-to-behavior-change-in-upstream-_parse.patch
new file mode 100644
index 0000000000..e2b34ab937
--- /dev/null
+++ b/meta-python/recipes-extended/python-pykickstart/files/0005-options-adjust-to-behavior-change-in-upstream-_parse.patch
@@ -0,0 +1,71 @@
1From f753d4d6ad1f4846d14735beb3d1b157b9914b51 Mon Sep 17 00:00:00 2001
2From: Adam Williamson <awilliam@redhat.com>
3Date: Wed, 2 Oct 2024 09:48:39 -0700
4Subject: [PATCH] options: adjust to behavior change in upstream
5 _parse_optional
6
7In Python 3.13 and 3.12.7, the behavior of _parse_optional has
8changed. It used to raise an error on multiple matching actions
9itself, and only ever return None or an option tuple. Now the
10"raise error on multiple matching actions" code was moved out
11into consume_optional, and _parse_optional returns either None
12or a *list* of option tuples, which contains more than one if
13multiple actions match. See:
14
15https://github.com/python/cpython/pull/124631
16https://github.com/python/cpython/issues/58573
17
18This adapts to the change in a way that should work on both older
19and newer Pythons.
20
21Signed-off-by: Adam Williamson <awilliam@redhat.com>
22
23Upstream-Status: Backport [https://github.com/pykickstart/pykickstart/commit/f753d4d]
24
25Signed-off-by: Kai Kang <kai.kang@windriver.com>
26---
27 pykickstart/options.py | 20 +++++++++++++++++---
28 1 file changed, 17 insertions(+), 3 deletions(-)
29
30diff --git a/pykickstart/options.py b/pykickstart/options.py
31index 2e3a0721..ca0e18af 100644
32--- a/pykickstart/options.py
33+++ b/pykickstart/options.py
34@@ -177,9 +177,23 @@ class KSOptionParser(ArgumentParser):
35 self.lineno = None
36
37 def _parse_optional(self, arg_string):
38- option_tuple = ArgumentParser._parse_optional(self, arg_string)
39+ # Before 3.13 and 3.12.7, this returned None or a single
40+ # option tuple. From 3.13 / 3.12.7 onwards it returns None
41+ # or a *list* of option tuples
42+ option_tuple_or_tuples = ArgumentParser._parse_optional(self, arg_string)
43+ # all we want to do here is a custom warning if the action is
44+ # deprecated. we can only safely do this if there's exactly
45+ # one matching action
46+ if isinstance(option_tuple_or_tuples, list):
47+ if len(option_tuple_or_tuples) == 1:
48+ option_tuple = option_tuple_or_tuples[0]
49+ else:
50+ return option_tuple_or_tuples
51+ else:
52+ option_tuple = option_tuple_or_tuples
53+
54 if option_tuple is None or option_tuple[0] is None:
55- return option_tuple
56+ return option_tuple_or_tuples
57
58 action = option_tuple[0]
59 option = action.option_strings[0]
60@@ -191,7 +205,7 @@ class KSOptionParser(ArgumentParser):
61 "kickstart. Please modify your kickstart file to remove this option.")
62 % {"lineno": self.lineno, "option": option}, KickstartDeprecationWarning)
63
64- return option_tuple
65+ return option_tuple_or_tuples
66
67 def add_argument(self, *args, **kwargs):
68 if "introduced" in kwargs:
69--
702.47.1
71
diff --git a/meta-python/recipes-extended/python-pykickstart/python3-pykickstart_3.48.bb b/meta-python/recipes-extended/python-pykickstart/python3-pykickstart_3.48.bb
index 9e074bddcf..0013762f0a 100644
--- a/meta-python/recipes-extended/python-pykickstart/python3-pykickstart_3.48.bb
+++ b/meta-python/recipes-extended/python-pykickstart/python3-pykickstart_3.48.bb
@@ -16,6 +16,7 @@ SRC_URI = "git://github.com/rhinstaller/pykickstart.git;protocol=https;branch=ma
16 file://0002-pykickstart-parser.py-add-lock-for-readKickstart-and.patch \ 16 file://0002-pykickstart-parser.py-add-lock-for-readKickstart-and.patch \
17 file://0003-comment-out-sections-shutdown-and-environment-in-gen.patch \ 17 file://0003-comment-out-sections-shutdown-and-environment-in-gen.patch \
18 file://0004-load.py-retry-to-invoke-request-with-timeout.patch \ 18 file://0004-load.py-retry-to-invoke-request-with-timeout.patch \
19 file://0005-options-adjust-to-behavior-change-in-upstream-_parse.patch \
19 " 20 "
20SRCREV = "fa6c80c0e5c6bee29d089899a10d26e6f7f8afd8" 21SRCREV = "fa6c80c0e5c6bee29d089899a10d26e6f7f8afd8"
21 22