[issue9005] Year range in timetuple

Alexander Belopolsky report at bugs.python.org
Sun Jun 20 03:29:20 CEST 2010

Alexander Belopolsky <belopolsky at users.sourceforge.net> added the comment:

Note that a recently closed issue 7150 similarly tightened up datetime operations by making out of range dates raise OverflowError rather than produce non-sensible result.  This case is not a clear cut, but now with timezone.utc available in datetime module, I believe users should be encouraged to use t.astimezone(timezone.utc) to produce UTC time.  If timetuple is required the later can be converted using timetuple() method.  Idelally, t.utctimetuple() should be deprecated in favor of more explicit t.astimezone(timezone.utc).timetuple().  Unfortunately the two expressions are subtly different because 

>>> t = datetime.max.replace(tzinfo=timezone.min)
>>> t.astimezone(timezone.utc)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: date value out of range

nosy: +gvanrossum

Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list