[Datetime-SIG] Are there any "correct" implementations of tzinfo?

Alexander Belopolsky alexander.belopolsky at gmail.com
Mon Sep 14 22:27:26 CEST 2015


On Mon, Sep 14, 2015 at 4:08 PM, Random832 <random832 at fastmail.com> wrote:

> On Mon, Sep 14, 2015, at 15:48, Alexander Belopolsky wrote:
> > On Mon, Sep 14, 2015 at 3:44 PM, Random832 <random832 at fastmail.com>
> > wrote:
> >
> > > It is an
> > > invariant that is true today, and therefore which you can't rely on any
> > > of the consumers of this 12 years old widely deployed code not to
> assume
> > > will remain true.
> > >
> >
> > Sorry, this sentence does not parse.  You are missing a "not" somewhere.
>
> Nope. I am asserting that:
>
> This invariant is true today.
>

You've never specified "this invariant", but I'll assume you are talking
about "a < b implies a.astimezone(UTC) < b.astimezone(UTC)."  This is *not*
true today:

>>> from datetime import *
>>> from datetimetester import Eastern
>>> UTC = timezone.utc
>>> a = datetime(2002, 4, 7, 1, 40, tzinfo=Eastern)
>>> b = datetime(2002, 4, 7, 2, 20, tzinfo=Eastern)
>>> a < b
True
>>> a.astimezone(UTC) < b.astimezone(UTC)
False



> Therefore, it is likely that at least some consumers of datetime will
> assume it is true.
>

Obviously, if Random832 is a real person, the last statement is true.  This
does not make the assumption true, just proves that at least one user is
confused about the current behavior. :-)


> Therefore, you cannot rely on there not being any consumers which assume
> it will remain true.
>

That's where we are now.  Some users make baseless assumptions.  This will
probably remain true. :-(


> It's awkward, since when I go back to analyze it it turns out that the
> "not" after 'code' actually technically modifies "any" earlier in the
> sentence, but the number of negatives is correct.


Writing in shorter sentences may help.


> (Though, it actually
> works out even without that change, since the question of *which*
> consumers rely on the invariant is unknown.)
>

True.  We will never know how many users rely on false assumptions.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20150914/f0e03c18/attachment.html>


More information about the Python-list mailing list