mx.DateTime bug?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Denis S. Otkidach

    mx.DateTime bug?


    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.[color=blue][color=green][color=darkred]
    >>> from mx import DateTime
    >>> DateTime.__vers ion__[/color][/color][/color]
    '2.0.3'[color=blue][color=green][color=darkred]
    >>> class c: pass[/color][/color][/color]
    ....[color=blue][color=green][color=darkred]
    >>> DateTime.now()= =c()[/color][/color][/color]
    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]


Working...