On Tue, Sep 22, 2015 at 10:34 AM, Tim Peters <tim.pet...@gmail.com> wrote:
> [Tim] > >> Sure - no complaint. I was just saying that in the specific, > >> complicated, contrived expression Nick presented, that it always > >> returns False (no matter which aware datetime he starts with) would be > >> more of a head-scratcher than if it raised a "can't compare naive and > >> aware datetimes" exception instead. > > [Guido] > > And yet I think the desired behavior of == requires us to return False. > > Yes - we remain in violent agreement on all points here. > > > > I think we should change this in the PEP, except I can't find where > > the PEP says == should raise an exception in this case. > > It doesn't - the only comparison behavior changed by the PEP is in > case of interzone comparison when at least one comparand is a "problem > time" (which can only happen with a post-495 tzinfo). Then "==" is > always False. That hack is the ugliest part of the PEP, but was > needed to preserve the hash invariant (d1 == d2 implies hash(d1) == > hash(d2)). > > BTW, while the PEP doesn't spell this out, trichotomy can fail in some > such cases (those where "==" would have returned True had it not been > forced to return False - then "<" and ">" will also be False). > > In any case, nothing changes for any case of aware-vs-naive comparison. > And I guess we can't make < and > raise an exception for backward compatibility reasons. :-( -- --Guido van Rossum (python.org/~guido)
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com