Fix ArrayType __eq__ operator so that array types are not duplicated in the registry.

This commit is contained in:
Christophe de Vienne 2012-09-14 10:49:04 +02:00
parent 1512c3902f
commit 110db71c8e
2 changed files with 7 additions and 0 deletions

View File

@ -318,3 +318,7 @@ class TestTypes(unittest.TestCase):
c = C1(s=six.u('test'))
assert c.s == six.u('test')
def test_array_eq(self):
l = [types.ArrayType(str)]
assert types.ArrayType(str) in l

View File

@ -30,6 +30,9 @@ class ArrayType(object):
def __hash__(self):
return hash(self.item_type)
def __eq__(self, other):
return self.item_type == other.item_type
@property
def item_type(self):
if isinstance(self._item_type, weakref.ref):