diff --git a/0001-Fix-the-fix-for-_parse_optional-changing.patch b/0001-Fix-the-fix-for-_parse_optional-changing.patch new file mode 100644 index 0000000..b76ae24 --- /dev/null +++ b/0001-Fix-the-fix-for-_parse_optional-changing.patch @@ -0,0 +1,28 @@ +From faf6a88a1be4558ebd26f5d52c0990f5dd3ca592 Mon Sep 17 00:00:00 2001 +From: Adam Williamson +Date: Wed, 2 Oct 2024 17:54:33 -0700 +Subject: [PATCH] Fix the fix for _parse_optional changing + +Whoops. Don't know how this slipped through testing. + +Signed-off-by: Adam Williamson +--- + pykickstart/options.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/pykickstart/options.py b/pykickstart/options.py +index ca0e18af..f0803039 100644 +--- a/pykickstart/options.py ++++ b/pykickstart/options.py +@@ -185,7 +185,7 @@ class KSOptionParser(ArgumentParser): + # deprecated. we can only safely do this if there's exactly + # one matching action + if isinstance(option_tuple_or_tuples, list): +- if len(option_tuple_or_tuples == 1): ++ if len(option_tuple_or_tuples) == 1: + option_tuple = option_tuple_or_tuples[0] + else: + return option_tuple_or_tuples +-- +2.46.2 + diff --git a/0001-options-adjust-to-behavior-change-in-upstream-_parse.patch b/0001-options-adjust-to-behavior-change-in-upstream-_parse.patch new file mode 100644 index 0000000..26062a9 --- /dev/null +++ b/0001-options-adjust-to-behavior-change-in-upstream-_parse.patch @@ -0,0 +1,67 @@ +From f753d4d6ad1f4846d14735beb3d1b157b9914b51 Mon Sep 17 00:00:00 2001 +From: Adam Williamson +Date: Wed, 2 Oct 2024 09:48:39 -0700 +Subject: [PATCH] options: adjust to behavior change in upstream + _parse_optional + +In Python 3.13 and 3.12.7, the behavior of _parse_optional has +changed. It used to raise an error on multiple matching actions +itself, and only ever return None or an option tuple. Now the +"raise error on multiple matching actions" code was moved out +into consume_optional, and _parse_optional returns either None +or a *list* of option tuples, which contains more than one if +multiple actions match. See: + +https://github.com/python/cpython/pull/124631 +https://github.com/python/cpython/issues/58573 + +This adapts to the change in a way that should work on both older +and newer Pythons. + +Signed-off-by: Adam Williamson +--- + pykickstart/options.py | 20 +++++++++++++++++--- + 1 file changed, 17 insertions(+), 3 deletions(-) + +diff --git a/pykickstart/options.py b/pykickstart/options.py +index 2e3a0721..ca0e18af 100644 +--- a/pykickstart/options.py ++++ b/pykickstart/options.py +@@ -177,9 +177,23 @@ class KSOptionParser(ArgumentParser): + self.lineno = None + + def _parse_optional(self, arg_string): +- option_tuple = ArgumentParser._parse_optional(self, arg_string) ++ # Before 3.13 and 3.12.7, this returned None or a single ++ # option tuple. From 3.13 / 3.12.7 onwards it returns None ++ # or a *list* of option tuples ++ option_tuple_or_tuples = ArgumentParser._parse_optional(self, arg_string) ++ # all we want to do here is a custom warning if the action is ++ # deprecated. we can only safely do this if there's exactly ++ # one matching action ++ if isinstance(option_tuple_or_tuples, list): ++ if len(option_tuple_or_tuples == 1): ++ option_tuple = option_tuple_or_tuples[0] ++ else: ++ return option_tuple_or_tuples ++ else: ++ option_tuple = option_tuple_or_tuples ++ + if option_tuple is None or option_tuple[0] is None: +- return option_tuple ++ return option_tuple_or_tuples + + action = option_tuple[0] + option = action.option_strings[0] +@@ -191,7 +205,7 @@ class KSOptionParser(ArgumentParser): + "kickstart. Please modify your kickstart file to remove this option.") + % {"lineno": self.lineno, "option": option}, KickstartDeprecationWarning) + +- return option_tuple ++ return option_tuple_or_tuples + + def add_argument(self, *args, **kwargs): + if "introduced" in kwargs: +-- +2.46.2 + diff --git a/pykickstart.spec b/pykickstart.spec index 0497140..67b532e 100644 --- a/pykickstart.spec +++ b/pykickstart.spec @@ -5,7 +5,7 @@ Name: pykickstart Version: 3.52 -Release: 1%{?dist} +Release: 3%{?dist} License: GPL-2.0-only AND MIT Summary: Python utilities for manipulating kickstart files. Url: http://fedoraproject.org/wiki/pykickstart @@ -17,6 +17,10 @@ Source0: %{name}-%{version}.tar.gz Source1: %{name}-%{version}.tar.gz.asc %endif +# Fix for python 3.12.7 and 3.13 +Patch0001: 0001-options-adjust-to-behavior-change-in-upstream-_parse.patch +Patch0002: 0001-Fix-the-fix-for-_parse_optional-changing.patch + BuildArch: noarch BuildRequires: gettext @@ -44,7 +48,7 @@ Python 3 library for manipulating kickstart files. The binaries are found in the pykickstart package. %prep -%setup -q +%autosetup -p1 %build make PYTHON=%{__python3} @@ -78,6 +82,12 @@ LC_ALL=C make PYTHON=%{__python3} test-no-coverage %{python3_sitelib}/pykickstart*.egg-info %changelog +* Wed Oct 02 2024 Adam Williamson - 3.52-3 +- Fix the fix for _parse_optional changing (awilliam) + +* Wed Oct 02 2024 Brian C. Lane - 3.52-2 +- options: adjust to behavior change in upstream _parse_optional (awilliam) + * Thu Feb 01 2024 Brian C. Lane - 3.52-1 - Deprecate %%packages --instLangs and --excludeWeakdeps kickstart options (vponcova) - Deprecate timezone --isUtc, --ntpservers and --nontp kickstart options (vponcova)