[IronPython] Lists of instances of classes

Giles Thomas giles.thomas at resolversystems.com
Wed Jan 4 19:09:26 CET 2006


Some more discoveries, following on from the below:

---------------
 >>> class D:
...   pass
...
 >>> d1 = D()
 >>> [c1, c2, c1] == [c1, c2, d1]
True
 >>> class E:
...   def __init__(self):
...     pass
...
 >>> e1 = E()
 >>> [c1, c2, c1] == [c1, c2, e1]
True
 >>> e1.foo = "bar"
 >>> [c1, c2, c1] == [c1, c2, e1]
True
---------------

Looks like it's just assuming all objects are identical.


Regards,

Giles


Giles Thomas wrote:
> Hi,
> 
> We've found what looks like a bug in list comparison:
> 
> ---------------
> IronPython 1.0.2190 (Beta) on .NET 2.0.50727.42
> Copyright (c) Microsoft Corporation. All rights reserved.
>  >>> class C:
> ...   pass
> ...
>  >>> c1 = C()
>  >>> c2 = C()
>  >>> [c1, c2] == [c2, c1]
> True
>  >>> [c1] == [c2]
> True
>  >>> c1 == c2
> False
>  >>>
> -----------------
> 
> Confirmed in 0.9.5, 0.9.6, and 1.0.2190
> 
> There is a horrible hack to work around it:
> 
> -----------------
>  >>> str([c1, c2]) == str([c2, c1])
> False
> -----------------
> 
> 
> Cheers,
> 
> Giles
> 



More information about the Ironpython-users mailing list