From b6f5ec737008f5c739ba3c667e1ae01b8625488b Mon Sep 17 00:00:00 2001 From: Alexander Belopolsky Date: Tue, 5 Apr 2011 20:07:38 -0400 Subject: Issue #11576: Fixed timedelta subtraction glitch on big timedelta values --- Lib/datetime.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Lib/datetime.py') 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): -- cgit v1.2.1