Skip to content

Commit

Permalink
Handle removal of ConfigParser.readfp() in Python 3.12
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
AdamWill authored and ckelleyRH committed Jul 5, 2023
1 parent a7ad636 commit 02b6fde
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion base/server/python/pki/server/deployment/pkiparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
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
Expand Down Expand Up @@ -342,7 +343,10 @@ def init_config(self, pki_instance_name=None):
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()

Expand Down

0 comments on commit 02b6fde

Please sign in to comment.