Message 94449 - Python tracker (original) (raw)

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 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 "", line 1, in OverflowError: date value out of range t0-d2 Traceback (most recent call last): File "", line 1, in OverflowError: date value out of range t0-d3 Traceback (most recent call last): File "", line 1, in OverflowError: date value out of range d0=datetime.timedelta(0) t0-d0 datetime.datetime(1, 1, 1, 0, 0)

Svn diff is attached.