[issue5516] equality not symmetric for subclasses of datetime.date and datetime.datetime

Alexander Belopolsky report at bugs.python.org
Wed Apr 21 17:27:36 CEST 2010


Alexander Belopolsky <alexander.belopolsky at gmail.com> added the comment:

There is another inconsistency that this patch does not seem to cure.  With patch applied and D and DT defined as in OP,

>>> D(1900,1,1) > DT(1900,1,1)
True

but

>>> DT(1900,1,1) < D(1900,1,1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: can't compare DT to D

and

>>> date(1900,1,1) < datetime(1900,1,1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: can't compare datetime.datetime to datetime.date

Note that without the patch,

>>> D(1900,1,1) > DT(1900,1,1)
False

but both behaviors seem to be wrong.

----------
nosy: +Alexander.Belopolsky

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5516>
_______________________________________


More information about the Python-bugs-list mailing list