[Datetime-SIG] Another round on error-checking

Carl Meyer carl at oddbird.net
Thu Sep 3 17:42:02 CEST 2015


On 09/03/2015 09:38 AM, Alexander Belopolsky wrote:
> On Thu, Sep 3, 2015 at 11:19 AM, Carl Meyer <carl at oddbird.net
> <mailto:carl at oddbird.net>> wrote:
>     >  This is unavoidable because
>     > within the same timezone fold=1 instances don't exist: 01:59 is followed
>     > by 02:00 with no room for "second 01:30" in between.
> 
>     Right. That's an excellent statement of why respecting `fold` at all is
>     inconsistent with how tz-annotated datetimes are designed to behave in
>     Python (they operate internally in naive time, in which the "fold" time
>     does not even exist).
> 
> I wish we could have a design where fold is always ignored when you have
> a single tzinfo.  The reason we cannot has been explained several times
> in this thread.  The core reason is possibly a mistake in the original
> design that permitted cross-zone arithmetic and comparison.  If == was
> defined so that no two instances with different tzinfo ever compare
> equal and <, - and friends are only defined for datetimes sharing the
> tzinfo, we would not have this problem.

Yes, I understand why that doesn't work. There is an alternative
solution available that avoids this problem, and all other inconsistencies.

> Recall that datetime was
> designed at the time when it was thought that mixing bytes and unicode
> was a good idea.  We all know what it took to fix that wart.   I don't
> think cross-zone datetime arithmetic is an issue of the same scale or
> impact. 

True. Which should make it more feasible to fix.

Carl

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/datetime-sig/attachments/20150903/4e869ee7/attachment-0001.sig>


More information about the Datetime-SIG mailing list