Sfoglia il codice sorgente

Fix DeviceInfo objects comparing

Do not crash if the other object is completely different type. Return
False ("unequal") instead.

This crashed preparing list of devices in qubes-vm-boot-from-device.

Fixes QubesOS/qubes-issues#3182
Marek Marczykowski-Górecki 6 anni fa
parent
commit
abc0d0063e
1 ha cambiato i file con 7 aggiunte e 4 eliminazioni
  1. 7 4
      qubesadmin/devices.py

+ 7 - 4
qubesadmin/devices.py

@@ -91,10 +91,13 @@ class DeviceInfo(object):
         return hash((str(self.backend_domain), self.ident))
 
     def __eq__(self, other):
-        return (
-            self.backend_domain == other.backend_domain and
-            self.ident == other.ident
-        )
+        try:
+            return (
+                self.backend_domain == other.backend_domain and
+                self.ident == other.ident
+            )
+        except AttributeError:
+            return False
 
     def __str__(self):
         return '{!s}:{!s}'.format(self.backend_domain, self.ident)