diff --git a/CHANGELOG.md b/CHANGELOG.md index 13cdfc7e3..2834152bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ ### Fixes - set a default error if NDN does not provide an error - +- python: avoid exceptions when messages/contacts/chats are compared with `None` ## 1.86.0 diff --git a/python/src/deltachat/chat.py b/python/src/deltachat/chat.py index effe73eb1..d546d4775 100644 --- a/python/src/deltachat/chat.py +++ b/python/src/deltachat/chat.py @@ -32,6 +32,8 @@ class Chat(object): self.id = id def __eq__(self, other) -> bool: + if other is None: + return False return self.id == getattr(other, "id", None) and self.account._dc_context == other.account._dc_context def __ne__(self, other) -> bool: diff --git a/python/src/deltachat/contact.py b/python/src/deltachat/contact.py index e79a737fd..69fa809b6 100644 --- a/python/src/deltachat/contact.py +++ b/python/src/deltachat/contact.py @@ -22,7 +22,9 @@ class Contact(object): self.account = account self.id = id - def __eq__(self, other): + def __eq__(self, other) -> bool: + if other is None: + return False return self.account._dc_context == other.account._dc_context and self.id == other.id def __ne__(self, other): diff --git a/python/src/deltachat/message.py b/python/src/deltachat/message.py index 597272614..ae77f5ffc 100644 --- a/python/src/deltachat/message.py +++ b/python/src/deltachat/message.py @@ -26,7 +26,9 @@ class Message(object): msg_id = self.id assert msg_id is not None and msg_id >= 0, repr(msg_id) - def __eq__(self, other): + def __eq__(self, other) -> bool: + if other is None: + return False return self.account == other.account and self.id == other.id def __repr__(self):