[libvirt] [PATCH 1/2] apibuild: Fix errors on python3

Cole Robinson posted 2 patches 7 years, 3 months ago
[libvirt] [PATCH 1/2] apibuild: Fix errors on python3
Posted by Cole Robinson 7 years, 3 months ago
Module 'string' function lower doesn't exist in python3. The canonical
way is to call .lower() on a str instance. Do that, and make the
exception handling more specific, which would have made this issue
obvious.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
---
 docs/apibuild.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/docs/apibuild.py b/docs/apibuild.py
index 67b7eed1e..e81980e3c 100755
--- a/docs/apibuild.py
+++ b/docs/apibuild.py
@@ -2326,10 +2326,10 @@ class docBuilder:
             for data in ('Summary', 'Description', 'Author'):
                 try:
                     output.write("     <%s>%s</%s>\n" % (
-                                 string.lower(data),
+                                 data.lower(),
                                  escape(dict.info[data]),
-                                 string.lower(data)))
-                except:
+                                 data.lower()))
+                except KeyError:
                     self.warning("Header %s lacks a %s description" % (module, data))
             if 'Description' in dict.info:
                 desc = dict.info['Description']
-- 
2.14.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/2] apibuild: Fix errors on python3
Posted by Daniel P. Berrangé 7 years, 3 months ago
On Fri, Mar 16, 2018 at 02:05:11PM -0400, Cole Robinson wrote:
> Module 'string' function lower doesn't exist in python3. The canonical
> way is to call .lower() on a str instance. Do that, and make the
> exception handling more specific, which would have made this issue
> obvious.
> 
> Signed-off-by: Cole Robinson <crobinso@redhat.com>
> ---
>  docs/apibuild.py | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


> 
> diff --git a/docs/apibuild.py b/docs/apibuild.py
> index 67b7eed1e..e81980e3c 100755
> --- a/docs/apibuild.py
> +++ b/docs/apibuild.py
> @@ -2326,10 +2326,10 @@ class docBuilder:
>              for data in ('Summary', 'Description', 'Author'):
>                  try:
>                      output.write("     <%s>%s</%s>\n" % (
> -                                 string.lower(data),
> +                                 data.lower(),
>                                   escape(dict.info[data]),
> -                                 string.lower(data)))
> -                except:
> +                                 data.lower()))
> +                except KeyError:
>                      self.warning("Header %s lacks a %s description" % (module, data))
>              if 'Description' in dict.info:
>                  desc = dict.info['Description']
> -- 
> 2.14.3
> 
> --
> libvir-list mailing list
> libvir-list@redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

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