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
This commit is contained in:
Marek Marczykowski-Górecki 2017-10-17 20:40:16 +02:00
parent d3ea2845cd
commit abc0d0063e
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

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