bpo-37685: Fixed __eq__, __lt__ etc implementations in some classes. (GH-14952)
They now return NotImplemented for unsupported type of the other operand.
diff --git a/Lib/email/headerregistry.py b/Lib/email/headerregistry.py
index 8d1a202..dcc960b 100644
--- a/Lib/email/headerregistry.py
+++ b/Lib/email/headerregistry.py
@@ -97,8 +97,8 @@
return self.addr_spec
def __eq__(self, other):
- if type(other) != type(self):
- return False
+ if not isinstance(other, Address):
+ return NotImplemented
return (self.display_name == other.display_name and
self.username == other.username and
self.domain == other.domain)
@@ -150,8 +150,8 @@
return "{}:{};".format(disp, adrstr)
def __eq__(self, other):
- if type(other) != type(self):
- return False
+ if not isinstance(other, Group):
+ return NotImplemented
return (self.display_name == other.display_name and
self.addresses == other.addresses)