From abc0d0063e313e6f6da332b19d0133325c191d9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Tue, 17 Oct 2017 20:40:16 +0200 Subject: [PATCH] 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 --- qubesadmin/devices.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/qubesadmin/devices.py b/qubesadmin/devices.py index a64cd14..3377a68 100644 --- a/qubesadmin/devices.py +++ b/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)