Re: [RFC PATCH v2 8/8] python3: Fix sort function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 15, 2018 at 05:11:10PM +0100, Andrea Bolognani wrote:
> This deals with cls.version possibly being None.
> 
> Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx>
> ---
> Really not sure about this one. The script runs all the way to
> the end after applying it, so there's that I guess.

Python2 sorts  None before "", which is in turn before
any other non-zero length string. eg

   None < "" < "a"

I'm thinking that cls.version doesn't care about the
distinction between None and "", so your change is
likely to be fine.

> 
>  src/hyperv/hyperv_wmi_generator.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/hyperv/hyperv_wmi_generator.py b/src/hyperv/hyperv_wmi_generator.py
> index 7dc11ba905..d548102117 100755
> --- a/src/hyperv/hyperv_wmi_generator.py
> +++ b/src/hyperv/hyperv_wmi_generator.py
> @@ -59,7 +59,7 @@ class WmiClass:
>          """
>          # sort vesioned classes by version in case input file did not have them
>          # in order
> -        self.versions = sorted(self.versions, key=lambda cls: cls.version)
> +        self.versions = sorted(self.versions, key=lambda cls: cls.version or "")
>  
>          # if there's more than one verion make sure first one has name suffixed
>          # because we'll generate "common" memeber and will be the "base" name

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


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@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux