When creating an int overflow via a subtraction operation with a datetime object and a timedelta object, the resulting datetime object can cause a segmentation fault when the ctime method is called. Segmentation Fault occurred on python 2.6.5 on 64 bit ubuntu lucid. Code as follows: from datetime import datetime, timedelta (datetime.now() - timedelta(734395)).ctime()
This does not reproduce for me on python2.6.5 gentoo linux; however, gentoo linux does have some additional post 2.6.5 patches applied. It also does not reproduce on 2.7.
After further investigation, it appears the cause is the ability to overflow the datetime object by almost a year. I've modified the test to demonstrate this relative to the current date: from datetime import date, datetime, timedelta (datetime.now()-timedelta((date.today()-date(1,1,1)).days+364)).ctime() It seems the date can be overflowed by up to a year without throwing an Exception. The result of which is a seg fault when calling the bound ctime method. Note that anything above 364 results in OverFlowError. Below 18 still overflows, but does not seg fault, instead resulting in a weird result,e.g.: 'Tue (null) 240 17:25:37 0001' I'll update the script to demonstrate the edge cases where this occurs.
Apparently it has been fixed somewhere between 2.6.5 and 2.6.6. I get a segmentation fault in 2.6.5, but an OverflowError in all of {2.6.6, 2.7, 3.1, 3.2}.