summaryrefslogtreecommitdiff
path: root/Lib/xmlrpc/client.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2019-08-08 08:42:54 +0300
committerGitHub <noreply@github.com>2019-08-08 08:42:54 +0300
commit662db125cddbca1db68116c547c290eb3943d98e (patch)
tree06151487dbe4493ef173dd8cc378f4b6cf5c0e4a /Lib/xmlrpc/client.py
parent4c69be22df3852f17873a74d015528d9a8ae92d6 (diff)
downloadcpython-git-662db125cddbca1db68116c547c290eb3943d98e.tar.gz
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/xmlrpc/client.py')
-rw-r--r--Lib/xmlrpc/client.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/Lib/xmlrpc/client.py b/Lib/xmlrpc/client.py
index b987574500..246ef27ffc 100644
--- a/Lib/xmlrpc/client.py
+++ b/Lib/xmlrpc/client.py
@@ -313,31 +313,38 @@ class DateTime:
s = self.timetuple()
o = other.timetuple()
else:
- otype = (hasattr(other, "__class__")
- and other.__class__.__name__
- or type(other))
- raise TypeError("Can't compare %s and %s" %
- (self.__class__.__name__, otype))
+ s = self
+ o = NotImplemented
return s, o
def __lt__(self, other):
s, o = self.make_comparable(other)
+ if o is NotImplemented:
+ return NotImplemented
return s < o
def __le__(self, other):
s, o = self.make_comparable(other)
+ if o is NotImplemented:
+ return NotImplemented
return s <= o
def __gt__(self, other):
s, o = self.make_comparable(other)
+ if o is NotImplemented:
+ return NotImplemented
return s > o
def __ge__(self, other):
s, o = self.make_comparable(other)
+ if o is NotImplemented:
+ return NotImplemented
return s >= o
def __eq__(self, other):
s, o = self.make_comparable(other)
+ if o is NotImplemented:
+ return NotImplemented
return s == o
def timetuple(self):