diff options
author | lovetox <philipp@hoerist.com> | 2020-04-13 16:50:09 +0300 |
---|---|---|
committer | lovetox <philipp@hoerist.com> | 2020-04-13 16:50:09 +0300 |
commit | 9ae48ff3497e497404732489f78a392209e07a63 (patch) | |
tree | 6e9ae60446cc83be5fea8e98f6eed306e6fa0dc0 /nbxmpp | |
parent | 2862f900e8d04d6321717ce44b09dca70a8c49c6 (diff) |
JID: Refactor __eq__()
Diffstat (limited to 'nbxmpp')
-rw-r--r-- | nbxmpp/protocol.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/nbxmpp/protocol.py b/nbxmpp/protocol.py index 9c7b8e7..7f57a30 100644 --- a/nbxmpp/protocol.py +++ b/nbxmpp/protocol.py @@ -911,12 +911,15 @@ class JID: """ Compare the JID to another instance or to string for equality """ - try: - other = JID(other) - except ValueError: - return 0 - return self.resource == other.resource and \ - self.__str__(0) == other.__str__(0) + if not isinstance(other, JID): + try: + other = JID(other) + except Exception: + return False + + return (self.node == other.node and + self.domain == other.domain and + self.resource == other.resource) def __ne__(self, other): """ |