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 pythonhacker
Recipients mark.leander, pythonhacker
Date 2009-10-25.09:29:48
SpamBayes Score 5.162537e-15
Marked as misclassified No
Message-id <1256462993.08.0.123568087978.issue7150@psf.upfronthosting.co.za>
In-reply-to
Content
The problem seems to be in the "normalize_date" function in
datetimemodule.c. It is checking for a valid year range, but not
checking for a valid month or day range. 

I have a patch which fixes this problem. It checks for month range
(1<=m<=12) and day range(1<=d<=31). Here is Python with the patch.

anand@anand-laptop:~/projects/python/py3k$ ./python
Python 3.2a0 (py3k:75627, Oct 25 2009, 14:28:21) 
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Traceback (most recent call last):
  File "/home/anand/.pythonrc", line 2, in <module>
    import readline
ImportError: No module named readline
>>> import datetime
>>> t0=datetime.datetime(1,1,1)
>>> d1,d2,d3=map(datetime.timedelta, range(1,4))
>>> t0-d1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: date value out of range
>>> t0-d2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: date value out of range
>>> t0-d3
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: date value out of range
>>> d0=datetime.timedelta(0)
>>> t0-d0
datetime.datetime(1, 1, 1, 0, 0)
>>> 

Svn diff is attached.
History
Date User Action Args
2009-10-25 09:29:53pythonhackersetrecipients: + pythonhacker, mark.leander
2009-10-25 09:29:53pythonhackersetmessageid: <1256462993.08.0.123568087978.issue7150@psf.upfronthosting.co.za>
2009-10-25 09:29:51pythonhackerlinkissue7150 messages
2009-10-25 09:29:49pythonhackercreate