[issue5094] datetime lacks concrete tzinfo impl. for UTC
Alexander Belopolsky
report at bugs.python.org
Tue May 25 04:18:14 CEST 2010
Alexander Belopolsky <belopolsky at users.sourceforge.net> added the comment:
I have two questions about the proposed implementation:
1. Why not follow pytz lead and expose an instance of UTC rather than the UTC class itself?
2. Is there a real need to add a boolean argument to utcnow()? I think timedelta.now(UTC()) or with utc = UTC() timedelta.now(utc) seems to be a more obvious way to produce TZ aware datetime.
If a singleton instance utc is exposed instead of UTC class, I would suggest to change its repr to 'datetime.utc'.
On the patch itself, datetime_utcnow() is missing an error check for PyObject_IsTrue() return value:
>>> class X:
... def __nonzero__(self): raise RuntimeError
...
>>> datetime.utcnow(tz_aware=X())
datetime.datetime(2010, 5, 25, 2, 12, 14, 739720, tzinfo=<datetime.UTC object at 0x1015aab80>)
XXX undetected error
..
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5094>
_______________________________________
More information about the Python-bugs-list
mailing list