1.1 --- a/micropython/data.py Tue Jun 05 01:30:05 2012 +0200
1.2 +++ b/micropython/data.py Tue Jun 05 01:54:54 2012 +0200
1.3 @@ -1303,6 +1303,7 @@
1.4 self.bases = []
1.5 self.descendants = set()
1.6 self.instattr = set() # instance attributes
1.7 + self.instattr_tentative = set() # tentative/suspected instance attributes
1.8 self.relocated = set() # attributes which do not have the same
1.9 # position as those of the same name in
1.10 # some superclasses
1.11 @@ -1446,8 +1447,11 @@
1.12 self.bases.append(base)
1.13 base.add_descendant(self)
1.14
1.15 - def add_instance_attribute(self, name):
1.16 - self.instattr.add(name)
1.17 + def add_instance_attribute(self, name, tentative=False):
1.18 + if tentative:
1.19 + self.instattr_tentative.add(name)
1.20 + else:
1.21 + self.instattr.add(name)
1.22
1.23 def add_descendant(self, cls):
1.24 self.descendants.add(cls)
1.25 @@ -1553,6 +1557,21 @@
1.26
1.27 "Make sure that the instance attributes are fully defined."
1.28
1.29 + # Eliminate tentative instance attributes that are actually class
1.30 + # attributes.
1.31 +
1.32 + for attrname in self.all_class_attributes().keys():
1.33 + if attrname in self.instattr_tentative:
1.34 + self.instattr_tentative.remove(attrname)
1.35 +
1.36 + for cls in self.descendants:
1.37 + for attrname in cls.class_attribute_names():
1.38 + if attrname in self.instattr_tentative:
1.39 + self.instattr_tentative.remove(attrname)
1.40 +
1.41 + for attrname in self.instattr_tentative:
1.42 + self.instattr.add(attrname)
1.43 +
1.44 # Cache the attributes by converting the positioned attributes into a
1.45 # dictionary.
1.46