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

Daniel P. Berrangé posted 1 patch 4 years, 11 months ago
Failed in applying to current master (apply log)
guests/lcitool | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
[libvirt] [jenkins-ci PATCH] lcitool: don't use SafeConfigParser under Python3
Posted by Daniel P. Berrangé 4 years, 11 months ago
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

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [jenkins-ci PATCH] lcitool: don't use SafeConfigParser under Python3
Posted by Andrea Bolognani 4 years, 11 months ago
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

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list