Add patch to fix readfp with python-3.12. Fixes rhbz#2239728

This commit is contained in:
Kevin Fenzi 2023-09-26 16:46:41 -07:00
parent b5d5e2a14b
commit 37644b67ea
2 changed files with 42 additions and 1 deletions

View File

@ -0,0 +1,35 @@
diff --color -Nur ansible-2.15.4.orig/lib/ansible/module_utils/facts/system/local.py ansible-2.15.4/lib/ansible/module_utils/facts/system/local.py
--- ansible-2.15.4.orig/lib/ansible/module_utils/facts/system/local.py 2023-09-11 15:11:17.000000000 -0700
+++ ansible-2.15.4/lib/ansible/module_utils/facts/system/local.py 2023-09-26 16:31:21.030496975 -0700
@@ -26,6 +26,7 @@
from ansible.module_utils._text import to_text
from ansible.module_utils.facts.utils import get_file_content
from ansible.module_utils.facts.collector import BaseFactCollector
+from ansible.module_utils.six import PY3
from ansible.module_utils.six.moves import configparser, StringIO
@@ -91,7 +92,10 @@
# if that fails read it with ConfigParser
cp = configparser.ConfigParser()
try:
- cp.readfp(StringIO(out))
+ if PY3:
+ cp.read_file(StringIO(out))
+ else:
+ cp.readfp(StringIO(out))
except configparser.Error:
fact = "error loading facts as JSON or ini - please check content: %s" % fn
module.warn(fact)
diff --color -Nur ansible-2.15.4.orig/lib/ansible/plugins/lookup/ini.py ansible-2.15.4/lib/ansible/plugins/lookup/ini.py
--- ansible-2.15.4.orig/lib/ansible/plugins/lookup/ini.py 2023-09-11 15:11:17.000000000 -0700
+++ ansible-2.15.4/lib/ansible/plugins/lookup/ini.py 2023-09-26 16:31:56.603461044 -0700
@@ -187,7 +187,7 @@
config.seek(0, os.SEEK_SET)
try:
- self.cp.readfp(config)
+ self.cp.read_file(config)
except configparser.DuplicateOptionError as doe:
raise AnsibleLookupError("Duplicate option in '{file}': {error}".format(file=paramvals['file'], error=to_native(doe)))

View File

@ -12,7 +12,7 @@ Name: ansible-core
Summary: A radically simple IT automation system
Version: 2.15.4
%global uversion %{version_no_tilde %{quote:%nil}}
Release: 1%{?dist}
Release: 2%{?dist}
# The main license is GPLv3+. Many of the files in lib/ansible/module_utils
# are BSD licensed. There are various files scattered throughout the codebase
# containing code under different licenses.
@ -44,6 +44,9 @@ Patch6000: https://github.com/ansible/ansible/commit/676b731e6f7d60ce6fd48c0d1c8
Patch6003: https://github.com/ansible/ansible/commit/742d47fa15a5418f98abf9aaf07edf466e871c81.patch#/replace-deprecated-ast.value.s.patch
# Avoid deprecated importlib.abc.TraversableResources (#81082)
Patch6004: https://github.com/ansible/ansible/commit/bd5b0b4293f454819766437cb6f8a7037affd49e.patch#/avoid-importlib-resources-abc-deprecation.patch
# Fix for readfp with python-3.12. Already upstream (rhbz#2239728)
# (rebased on top of above patches)
Patch6005: https://github.com/ansible/ansible/commit/a861b1adba5d4a12f61ed268f67a224bdaa5f835.patch
Url: https://ansible.com
BuildArch: noarch
@ -285,6 +288,9 @@ install -Dpm 0644 licenses/* -t %{buildroot}%{_pkglicensedir}
%changelog
* Tue Sep 26 2023 Kevin Fenzi <kevin@scrye.com> - 2.15.4-2
- Add patch to fix readfp with python-3.12. Fixes rhbz#2239728
* Mon Sep 11 2023 Maxwell G <maxwell@gtmx.me> - 2.15.4-1
- Update to 2.15.4. Fixes rhbz#2238445.