New submission from Jess Austin <jess.aus...@gmail.com>: While the datetime.date and datetime.datetime classes consistently handle mixed-type comparison, their subclasses do not:
>>> from datetime import date, datetime, time >>> d = date.today() >>> dt = datetime.combine(d, time()) >>> d == dt False >>> dt == d False >>> class D(date): ... pass ... >>> class DT(datetime): ... pass ... >>> d = D.today() >>> dt = DT.combine(d, time()) >>> d == dt True >>> dt == d False I think this is due to the premature "optimization" of using memcmp() in date_richcompare(). ---------- components: Library (Lib) messages: 83798 nosy: jess.austin severity: normal status: open title: equality not reflixive for subclasses of datetime.date and datetime.datetime type: behavior versions: Python 2.4, Python 2.5, Python 2.6, Python 2.7, Python 3.0, Python 3.1 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue5516> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com