[Python-Dev] Year 0 and year 10,000 in timetuple (original) (raw)

Alexander Belopolsky alexander.belopolsky at gmail.com
Sat Jun 19 22:43:18 CEST 2010


While datetime range is limited to years from 1 through 9999, it is possible to produce time tuple with year 0 or year 10,000:

t1 = datetime.min.replace(tzinfo=timezone.max) t2 = datetime.max.replace(tzinfo=timezone.min) t1.utctimetuple().tmyear 0 t2.utctimetuple().tmyear 10000

Most if not all functions consuming timetuples are not designed to handle years beyond 9999 and such timetuples cannot be converted back to datetime.

I would like to make utctimetuple() method to raise OverflowError on values like t1 or t2 above. These values are most certainly a mistake in application ad it is better to detect them earlier before they make their way into system functions that cannot handle them.

See issues 9005 and 6608 on the tracker.

http://bugs.python.org/issue9005 http://bugs.python.org/issue6608



More information about the Python-Dev mailing list