summaryrefslogtreecommitdiffstats
path: root/Lib/email
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2019-08-08 05:42:54 (GMT)
committerGitHub <noreply@github.com>2019-08-08 05:42:54 (GMT)
commit662db125cddbca1db68116c547c290eb3943d98e (patch)
tree06151487dbe4493ef173dd8cc378f4b6cf5c0e4a /Lib/email
parent4c69be22df3852f17873a74d015528d9a8ae92d6 (diff)
downloadcpython-662db125cddbca1db68116c547c290eb3943d98e.zip
cpython-662db125cddbca1db68116c547c290eb3943d98e.tar.gz
cpython-662db125cddbca1db68116c547c290eb3943d98e.tar.bz2
bpo-37685: Fixed __eq__, __lt__ etc implementations in some classes. (GH-14952)
They now return NotImplemented for unsupported type of the other operand.
Diffstat (limited to 'Lib/email')
-rw-r--r--Lib/email/headerregistry.py8
1 files changed, 4 insertions, 4 deletions
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 @@ class Address:
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 @@ class Group:
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)