Message94132
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)
>>> |
|
Date |
User |
Action |
Args |
2009-10-16 09:45:30 | mark.leander | set | recipients:
+ mark.leander |
2009-10-16 09:45:29 | mark.leander | set | messageid: <1255686329.97.0.65785065346.issue7150@psf.upfronthosting.co.za> |
2009-10-16 09:45:28 | mark.leander | link | issue7150 messages |
2009-10-16 09:45:27 | mark.leander | create | |
|