summaryrefslogtreecommitdiff
path: root/Lib/datetime.py
diff options
context:
space:
mode:
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>2011-04-05 20:43:15 -0400
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>2011-04-05 20:43:15 -0400
commit28deea1fa56379f88f3a726c8145ec893c2040d5 (patch)
treee3072b2836cb3ed82fad4c55df91d596d458952f /Lib/datetime.py
parent3bd9729dc92ad3fc57aee17479231eb426fd076f (diff)
parentb6f5ec737008f5c739ba3c667e1ae01b8625488b (diff)
downloadcpython-git-28deea1fa56379f88f3a726c8145ec893c2040d5.tar.gz
Issue #11576: Fixed timedelta subtraction glitch on big timedelta values
Diffstat (limited to 'Lib/datetime.py')
-rw-r--r--Lib/datetime.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/datetime.py b/Lib/datetime.py
index 47e54ec235..1ae7cb5305 100644
--- a/Lib/datetime.py
+++ b/Lib/datetime.py
@@ -485,7 +485,11 @@ class timedelta:
def __sub__(self, other):
if isinstance(other, timedelta):
- return self + -other
+ # for CPython compatibility, we cannot use
+ # our __class__ here, but need a real timedelta
+ return timedelta(self._days - other._days,
+ self._seconds - other._seconds,
+ self._microseconds - other._microseconds)
return NotImplemented
def __rsub__(self, other):