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 mark.leander
Recipients mark.leander
Date 2009-10-16.09:45:27
SpamBayes Score 1.0162482e-11
Marked as misclassified No
Message-id <1255686329.97.0.65785065346.issue7150@psf.upfronthosting.co.za>
In-reply-to
Content
The datetime module documentation would imply that operations that cause
dates to fall outside the MINYEAR--MAXYEAR range should raise
OverflowError. The interpreter session below shows that this is not
always the case, and that such operations may cause bogus and
inconsistent results.

Python 2.6.3 (r263rc1:75186, Oct  2 2009, 20:40:30) [MSC v.1500 32 bit
(Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> t0=datetime.datetime(1,1,1)
>>> d1, d2, d3 = map(datetime.timedelta, range(1,4))
# The following is expected and accoring to the docs:
>>> t0-d1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: date value out of range

# The following is completely bogus:
>>> t0-d2
datetime.datetime(1, 0, 255, 0, 0)

# The two following behaving differently may be very confusing,
# the second one is correct
>>> t0-d2+d3
datetime.datetime(1, 8, 15, 0, 0)
>>> t0+d3-d2
datetime.datetime(1, 1, 2, 0, 0)
>>>
History
Date User Action Args
2009-10-16 09:45:30mark.leandersetrecipients: + mark.leander
2009-10-16 09:45:29mark.leandersetmessageid: <1255686329.97.0.65785065346.issue7150@psf.upfronthosting.co.za>
2009-10-16 09:45:28mark.leanderlinkissue7150 messages
2009-10-16 09:45:27mark.leandercreate