This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Chris.Bergstresser
Recipients Chris.Bergstresser
Date 2012-05-09.22:11:09
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1336601470.15.0.633873123281.issue14766@psf.upfronthosting.co.za>
In-reply-to
Content
The datetime module says:

An object d of type time or datetime may be naive or aware. d is aware if d.tzinfo is not None and d.tzinfo.utcoffset(d) does not return None. If d.tzinfo is None, or if d.tzinfo is not None but d.tzinfo.utcoffset(d) returns None, d is naive.

However, I can create two non-naive timezones (under this definition) which throw an exception when they're compared, because one is being considered offset-naive:

>>> import pytz, datetime
>>> UTC_TZ = pytz.utc
>>> EASTERN_TZ = pytz.timezone('America/New_York')
>>> d1 = datetime.time(10, tzinfo = UTC_TZ)
>>> d1
datetime.time(10, 0, tzinfo=<UTC>)
>>> d1.tzinfo
<UTC>
>>> d1.utcoffset(d1)
datetime.timedelta(0)
>>> d2 = datetime.time(10, tzinfo = EASTERN_TZ)
>>> d2
datetime.time(10, 0, tzinfo=<DstTzInfo 'America/New_York' EST-1 day, 19:00:00 STD>)
>>> d2.tzinfo
<DstTzInfo 'America/New_York' EST-1 day, 19:00:00 STD>
>>> d2.tzinfo.utcoffset(d2)
datetime.timedelta(-1, 68400)
>>> d1 < d2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: can't compare offset-naive and offset-aware times
History
Date User Action Args
2012-05-09 22:11:10Chris.Bergstressersetrecipients: + Chris.Bergstresser
2012-05-09 22:11:10Chris.Bergstressersetmessageid: <1336601470.15.0.633873123281.issue14766@psf.upfronthosting.co.za>
2012-05-09 22:11:09Chris.Bergstresserlinkissue14766 messages
2012-05-09 22:11:09Chris.Bergstressercreate