mx.DateTime bug?

Denis S. Otkidach ods at strana.ru
Tue May 11 09:07:26 EDT 2004


DateTime objects always compare equal to instances of
user-defined classes:

Python 2.3.2 (#1, Nov 27 2003, 18:07:14)
[GCC 3.2] on linux2
Type "help", "copyright", "credits" or "license" for more
information.
>>> from mx import DateTime
>>> DateTime.__version__
'2.0.3'
>>> class c: pass
...
>>> DateTime.now()==c()
True

Documentations states that "DateTime and DateTimeDelta instances
can be compared and hashed, making them compatible to the
dictionary implementation Python uses (they can be used as
keys)", but there is at least race condition when instance of
user defined class has the same hash value.  Moreover, making
DateTime objects to be always equal to instances with unknown
nature is a bad idea.

-- 
Denis S. Otkidach
http://www.python.ru/      [ru]





More information about the Python-list mailing list