From 363b7a165486ee9ace949bc201fc439284511d45 Mon Sep 17 00:00:00 2001 From: Remy Noel Date: Fri, 1 Sep 2023 17:11:11 +0200 Subject: [PATCH] fix: handling of None messages from notify callback This is especially common as BaseMessageBus._finalize calls handler(None, err) when an exception is raised. --- src/dbus_fast/message_bus.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dbus_fast/message_bus.py b/src/dbus_fast/message_bus.py index 2fe9af79..57615241 100644 --- a/src/dbus_fast/message_bus.py +++ b/src/dbus_fast/message_bus.py @@ -1194,7 +1194,7 @@ def add_match_notify(msg, err): logging.error( f'add match request failed. match="{self._name_owner_match_rule}", {err}' ) - if msg.message_type == MessageType.ERROR: + elif msg.message_type == MessageType.ERROR: logging.error( f'add match request failed. match="{self._name_owner_match_rule}", {msg.body[0]}' ) @@ -1228,7 +1228,7 @@ def _add_match_rule(self, match_rule): def add_match_notify(msg: Message, err: Optional[Exception]) -> None: if err: logging.error(f'add match request failed. match="{match_rule}", {err}') - if msg.message_type == MessageType.ERROR: + elif msg.message_type == MessageType.ERROR: logging.error( f'add match request failed. match="{match_rule}", {msg.body[0]}' ) @@ -1267,7 +1267,7 @@ def remove_match_notify(msg, err): logging.error( f'remove match request failed. match="{match_rule}", {err}' ) - if msg.message_type == MessageType.ERROR: + elif msg.message_type == MessageType.ERROR: logging.error( f'remove match request failed. match="{match_rule}", {msg.body[0]}' )