This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author belopolsky
Recipients SilentGhost, belopolsky, enrico, mark.dickinson
Date 2011-04-05.17:39:39
SpamBayes Score 5.4831695e-12
Marked as misclassified No
Message-id <1302025185.46.0.542055175062.issue11576@psf.upfronthosting.co.za>
In-reply-to
Content
> What happens is the second value is negated (__neg__)
> which causes it to become less than timedelta.min and
> that is causing OverflowError.

Yes, and running the test case without C acceleration makes this obvious:

>>> import sys
>>> sys.modules['_datetime'] = None
>>> from datetime import *
>>> timedelta(999999999, 86399, 999999) - timedelta(999999999, 86399, 999998)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "Lib/datetime.py", line 488, in __sub__
    return self + -other
  File "Lib/datetime.py", line 501, in __neg__
    -self._microseconds)
  File "Lib/datetime.py", line 426, in __new__
    raise OverflowError("timedelta # of days is too large: %d" % d)
OverflowError: timedelta # of days is too large: -1000000000

Attached patch fixes the issue.  I would like to think some more about C int overflow before committing.
History
Date User Action Args
2011-04-05 17:39:45belopolskysetrecipients: + belopolsky, mark.dickinson, SilentGhost, enrico
2011-04-05 17:39:45belopolskysetmessageid: <1302025185.46.0.542055175062.issue11576@psf.upfronthosting.co.za>
2011-04-05 17:39:40belopolskylinkissue11576 messages
2011-04-05 17:39:39belopolskycreate