From 1b53de83657d36a2bac1f6bd73ecc3f2fbd1fce5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Mon, 9 Dec 2019 21:05:18 +0100 Subject: [PATCH] Fixed Exceptions inferiting from KeyError Due to strangeness of KeyError (it overrrides str method) in some cases exceptions received superflous quotation marks when inheriting from it. fixes QubesOS/qubes-issues#5106 --- qubesadmin/exc.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/qubesadmin/exc.py b/qubesadmin/exc.py index abad4a4..7256b95 100644 --- a/qubesadmin/exc.py +++ b/qubesadmin/exc.py @@ -33,6 +33,10 @@ class QubesException(Exception): class QubesVMNotFoundError(QubesException, KeyError): '''Domain cannot be found in the system''' + def __str__(self): + # KeyError overrides __str__ method + return QubesException.__str__(self) + class QubesVMError(QubesException): '''Some problem with domain state.''' @@ -122,10 +126,16 @@ class QubesMemoryError(QubesException, MemoryError): class QubesFeatureNotFoundError(QubesException, KeyError): '''Feature not set for a given domain''' + def __str__(self): + # KeyError overrides __str__ method + return QubesException.__str__(self) class QubesTagNotFoundError(QubesException, KeyError): '''Tag not set for a given domain''' + def __str__(self): + # KeyError overrides __str__ method + return QubesException.__str__(self) class StoragePoolException(QubesException): @@ -139,6 +149,9 @@ class QubesDaemonCommunicationError(QubesException, IOError): class DeviceAlreadyAttached(QubesException, KeyError): '''Trying to attach already attached device''' + def __str__(self): + # KeyError overrides __str__ method + return QubesException.__str__(self) # pylint: disable=too-many-ancestors