From 666e66c1f3f1d21b0b63cc9e4bbbb3eb263513aa Mon Sep 17 00:00:00 2001 From: Michal Reznik Date: Sat, 13 Apr 2024 11:18:40 +0200 Subject: [PATCH 19/23] draft: Fix SafeConfigParser error AttributeError: module 'configparser' has no attribute 'SafeConfigParser' --- leapp/messaging/answerstore.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/leapp/messaging/answerstore.py b/leapp/messaging/answerstore.py index b2c707d..afd28dc 100644 --- a/leapp/messaging/answerstore.py +++ b/leapp/messaging/answerstore.py @@ -2,6 +2,10 @@ import multiprocessing import six from six.moves import configparser +try: + from six.moves.configparser import SafeConfigParser as ConfigParser +except ImportError: + from six.moves.configparser import ConfigParser from leapp.exceptions import CommandError from leapp.utils.audit import create_audit_entry @@ -46,10 +50,11 @@ class AnswerStore(object): Loads an ini config file from the given location. :param inifile: Path to the answer file to load. - :return: configparser.SafeConfigParser object + :return: configparser.ConfigParser object :raises CommandError if any of the values are not in key=value format """ - conf = configparser.SafeConfigParser(allow_no_value=False) + conf = ConfigParser(allow_no_value=False) + try: conf.read(inifile) return conf -- 2.42.0