Fix self reference complex type registration

This commit is contained in:
Christophe de Vienne
2011-10-24 16:42:54 +02:00
parent bbe98838ff
commit fd3475a9f3
2 changed files with 12 additions and 0 deletions

View File

@@ -113,3 +113,11 @@ class TestTypes(unittest.TestCase):
types.register_type(Child)
def test_selfreftype(self):
class SelfRefType(object):
pass
SelfRefType.parent = SelfRefType
types.register_type(SelfRefType)

View File

@@ -103,6 +103,9 @@ def sort_attributes(class_, attributes):
aname = line[:line.index('=')]
if aname in names and aname not in names_order:
names_order.append(aname)
if len(names_order) < len(names):
names_order.extend((
name for name in names if name not in names_order))
assert len(names_order) == len(names)
except (TypeError, IOError):
names_order = list(names)
@@ -156,6 +159,7 @@ def register_type(class_):
array_types.append(class_[0])
return
class_._wsme_attributes = None
class_._wsme_attributes = inspect_class(class_)
complex_types.append(weakref.ref(class_))