[libvirt] [jenkins-ci PATCH] lcitool: don't use SafeConfigParser under Python3

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@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

On Fri, 2019-05-03 at 11:02 +0100, Daniel P. Berrangé wrote:
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@redhat.com> --- guests/lcitool | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Reviewed-by: Andrea Bolognani <abologna@redhat.com> -- Andrea Bolognani / Red Hat / Virtualization
participants (2)
-
Andrea Bolognani
-
Daniel P. Berrangé