New submission from Enrico Zini <[email protected]>:
Hello,
I was testing edge case behaviour of some code of mine and stumbled into this
unexpected domain error from timedelta:
>>> from datetime import *
>>> timedelta(999999999, 86399, 999999) - timedelta(999999999, 86399, 999998)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
OverflowError: days=-1000000000; must have magnitude <= 999999999
>>>
The expected result is of course timedelta(0, 0, 1):
>>> timedelta(999999999, 86399, 999998) + timedelta(0, 0, 1)
datetime.timedelta(999999999, 86399, 999999)
Both time deltas are within the range documented in
/usr/share/doc/python-doc/html/lib/datetime-timedelta.html
I could reproduce it on 2.6.6 and 3.1.3. I don't have access to other python
versions.
Ciao,
Enrico
Note: I reported it 4 years ago in the Debian BTS
(http://bugs.debian.org/408872) but I noticed now that the Debian maintainer
doesn't seem to have bothered forwarding it here :(
----------
messages: 131155
nosy: enrico
priority: normal
severity: normal
status: open
title: timedelta subtraction glitch on big timedelta values
type: behavior
versions: Python 2.5, Python 2.6, Python 2.7, Python 3.1
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue11576>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com