Since Python 3.2 the SafeConfigParser class is renamed to
just ConfigParser. The SafeConfigParser alias is targetted
for deletion.
./lcitool:224: DeprecationWarning: The SafeConfigParser class
has been renamed to ConfigParser in Python 3.2. This alias
will be removed in future versions. Use ConfigParser directly
instead.
This switches to use ConfigParser all the time on Py3. Technically
this is wrong on 3.0 and 3.1, but in reality no one will still be
using those, only more modern 3.x versions, or the legacy 2.7.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
guests/lcitool | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/guests/lcitool b/guests/lcitool
index d3937be..1c18b5a 100755
--- a/guests/lcitool
+++ b/guests/lcitool
@@ -31,9 +31,9 @@ import yaml
# This is necessary to maintain Python 2.7 compatibility
try:
- import configparser
+ from configparser import ConfigParser
except ImportError:
- import ConfigParser as configparser
+ from ConfigParser import SafeConfigParser as ConfigParser
class Util:
@@ -221,7 +221,7 @@ class Inventory:
ansible_cfg_path = os.path.join(base, "ansible.cfg")
try:
- parser = configparser.SafeConfigParser()
+ parser = ConfigParser()
parser.read(ansible_cfg_path)
inventory_path = parser.get("defaults", "inventory")
except Exception as ex:
--
2.21.0