[pypy-commit] pypy py3.6: Backport more fixes to comparisons in datetime.py (bpo-37985)
rlamy
pypy.commits at gmail.com
Sun Oct 20 08:08:53 EDT 2019
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: py3.6
Changeset: r97824:405ad10a4ddc
Date: 2019-10-20 13:08 +0100
http://bitbucket.org/pypy/pypy/changeset/405ad10a4ddc/
Log: Backport more fixes to comparisons in datetime.py (bpo-37985)
diff --git a/lib-python/3/datetime.py b/lib-python/3/datetime.py
--- a/lib-python/3/datetime.py
+++ b/lib-python/3/datetime.py
@@ -615,25 +615,25 @@
if isinstance(other, timedelta):
return self._cmp(other) <= 0
else:
- _cmperror(self, other)
+ return NotImplemented
def __lt__(self, other):
if isinstance(other, timedelta):
return self._cmp(other) < 0
else:
- _cmperror(self, other)
+ return NotImplemented
def __ge__(self, other):
if isinstance(other, timedelta):
return self._cmp(other) >= 0
else:
- _cmperror(self, other)
+ return NotImplemented
def __gt__(self, other):
if isinstance(other, timedelta):
return self._cmp(other) > 0
else:
- _cmperror(self, other)
+ return NotImplemented
def _cmp(self, other):
assert isinstance(other, timedelta)
@@ -1150,25 +1150,25 @@
if isinstance(other, time):
return self._cmp(other) <= 0
else:
- _cmperror(self, other)
+ return NotImplemented
def __lt__(self, other):
if isinstance(other, time):
return self._cmp(other) < 0
else:
- _cmperror(self, other)
+ return NotImplemented
def __ge__(self, other):
if isinstance(other, time):
return self._cmp(other) >= 0
else:
- _cmperror(self, other)
+ return NotImplemented
def __gt__(self, other):
if isinstance(other, time):
return self._cmp(other) > 0
else:
- _cmperror(self, other)
+ return NotImplemented
def _cmp(self, other, allow_mixed=False):
assert isinstance(other, time)
@@ -2048,9 +2048,9 @@
return (self._offset, self._name)
def __eq__(self, other):
- if type(other) != timezone:
- return False
- return self._offset == other._offset
+ if isinstance(other, timezone):
+ return self._offset == other._offset
+ return NotImplemented
def __hash__(self):
return hash(self._offset)
More information about the pypy-commit
mailing list