From 0f6b462bcd68e6dfed5ade4319296e0ccea13440 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Tue, 4 Jul 2023 16:10:01 -0700 Subject: [PATCH] Backport PR #4494 to fix pkiparser.py with Python 3.12 --- ...f-ConfigParser.readfp-in-Python-3.12.patch | 45 +++++++++++++++++++ dogtag-pki.spec | 13 ++++-- 2 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 0001-Handle-removal-of-ConfigParser.readfp-in-Python-3.12.patch diff --git a/0001-Handle-removal-of-ConfigParser.readfp-in-Python-3.12.patch b/0001-Handle-removal-of-ConfigParser.readfp-in-Python-3.12.patch new file mode 100644 index 0000000..53ff4bc --- /dev/null +++ b/0001-Handle-removal-of-ConfigParser.readfp-in-Python-3.12.patch @@ -0,0 +1,45 @@ +From 584e9f2c07b6e23e92c09a34b0a3cb8107d696da Mon Sep 17 00:00:00 2001 +From: Adam Williamson +Date: Tue, 4 Jul 2023 16:02:41 -0700 +Subject: [PATCH] Handle removal of ConfigParser.readfp() in Python 3.12 + +Per https://docs.python.org/3.12/whatsnew/3.12.html#removed , +configparser.ConfigParser.readfp() is removed in Python 3.12. +Assuming we still want to keep Python 2 compatibility, since +there are still a bunch of uses of six in the codebase, I've +changed this to do it the same way as it's done in freeipa +ipaserver/install/certs.py, using readfp on Python 2 and +read_file on Python 3. + +Signed-off-by: Adam Williamson +--- + base/server/python/pki/server/deployment/pkiparser.py | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/base/server/python/pki/server/deployment/pkiparser.py b/base/server/python/pki/server/deployment/pkiparser.py +index 25322cbf4..d8143237f 100644 +--- a/base/server/python/pki/server/deployment/pkiparser.py ++++ b/base/server/python/pki/server/deployment/pkiparser.py +@@ -29,6 +29,7 @@ import logging + import os + import string + ++import six + from six.moves import input # pylint: disable=W0622,F0401 + from six.moves import configparser # pylint: disable=F0401 + from six.moves.urllib.parse import urlparse # pylint: disable=F0401,E0611 +@@ -342,7 +343,10 @@ class PKIConfigParser: + self.deployer.user_config.optionxform = str + + with open(config.default_deployment_cfg, encoding='utf-8') as f: +- self.deployer.main_config.readfp(f) ++ if six.PY2: ++ self.deployer.main_config.readfp(f) ++ else: ++ self.deployer.main_config.read_file(f) + + self.deployer.flatten_master_dict() + +-- +2.41.0 + diff --git a/dogtag-pki.spec b/dogtag-pki.spec index f25103b..48586f8 100644 --- a/dogtag-pki.spec +++ b/dogtag-pki.spec @@ -14,7 +14,7 @@ Name: dogtag-pki # Downstream release number: # - development/stabilization (unsupported): 0. where n >= 1 # - GA/update (supported): where n >= 1 -%global release_number 1 +%global release_number 2 # Development phase: # - development (unsupported): alpha where n >= 1 @@ -30,7 +30,7 @@ URL: https://www.dogtagpki.org # The entire source code is GPLv2 except for 'pki-tps' which is LGPLv2 License: GPL-2.0-only and LGPL-2.0-only Version: %{major_version}.%{minor_version}.%{update_version} -Release: %{release_number}%{?phase:.}%{?phase}%{?timestamp:.}%{?timestamp}%{?commit_id:.}%{?commit_id}%{?dist}.1 +Release: %{release_number}%{?phase:.}%{?phase}%{?timestamp:.}%{?timestamp}%{?commit_id:.}%{?commit_id}%{?dist} # To create a tarball from a version tag: # $ git archive \ @@ -47,6 +47,10 @@ Source: https://github.com/dogtagpki/pki/archive/v%{version}%{?phase:-}%{?phase} # > pki-VERSION-RELEASE.patch # Patch: pki-VERSION-RELEASE.patch +# https://github.com/dogtagpki/pki/pull/4494 +# Fix pkiparser.py to work with Python 3.12 +Patch0: 0001-Handle-removal-of-ConfigParser.readfp-in-Python-3.12.patch + %if 0%{?fedora} && 0%{?fedora} > 35 ExclusiveArch: %{java_arches} %else @@ -1297,7 +1301,10 @@ fi ################################################################################ %changelog -* Wed Jun 28 2023 Python Maint - 11.4.3-1.1 +* Tue Jul 04 2023 Adam Williamson - 11.4.3-2.fc39 +- Backport PR #4494 to fix pkiparser.py with Python 3.12 + +* Wed Jun 28 2023 Python Maint - 11.4.3-1.fc39.1 - Rebuilt for Python 3.12 * Mon Feb 27 2023 Jerry James - 11.3.1-2