1.1 --- a/micropython/data.py Sat Feb 26 01:12:25 2011 +0100
1.2 +++ b/micropython/data.py Sun Feb 27 02:45:38 2011 +0100
1.3 @@ -958,7 +958,7 @@
1.4 as a class or a module.
1.5 """
1.6
1.7 - return isinstance(self.parent, (Class, Module)) and self.name != "__class__"
1.8 + return isinstance(self.parent, (Class, Module))
1.9
1.10 def defines_ambiguous_class(self):
1.11
1.12 @@ -1159,20 +1159,18 @@
1.13 self.local_usage = 0
1.14 self.all_local_usage = 0
1.15
1.16 - # Add __class__ attributes to this class and to instances of it.
1.17 -
1.18 - if self.parent is not None:
1.19 - self.initialise_class_attribute()
1.20 - self.add_instance_attribute("__class__")
1.21 + # Add an attribute to this class for use by instances.
1.22 +
1.23 + self.set("__class__", self)
1.24
1.25 def set_context(self, parent, module, node):
1.26 +
1.27 + "Set the 'parent', 'module' and 'node' of a class created in advance."
1.28 +
1.29 self.parent = parent
1.30 self.module = module
1.31 self.astnode = node
1.32
1.33 - self.initialise_class_attribute()
1.34 - self.add_instance_attribute("__class__")
1.35 -
1.36 def reset_caches(self):
1.37
1.38 "Reset the caches."
1.39 @@ -1398,13 +1396,7 @@
1.40 # instance.
1.41
1.42 for name in self.instattr:
1.43 -
1.44 - # Special case: __class__ has to be at position 0.
1.45 -
1.46 - if name == "__class__":
1.47 - instattr[name] = set([0])
1.48 - else:
1.49 - instattr[name] = set() # position not yet defined
1.50 + instattr[name] = set() # position not yet defined
1.51
1.52 reversed_bases = self.bases[:]
1.53 reversed_bases.reverse()
1.54 @@ -1498,8 +1490,8 @@
1.55 Return all attributes for an instance, indicating either the class which
1.56 provides them or that the instance itself provides them.
1.57
1.58 - Note that __class__ acts like an instance attribute for both instances
1.59 - and classes.
1.60 + Note that __class__ acts like a class attribute for both instances and
1.61 + classes, and must be able to convey distinct values.
1.62 """
1.63
1.64 if self.allattr is None:
1.65 @@ -1515,15 +1507,13 @@
1.66
1.67 "A special class for the type class."
1.68
1.69 - def initialise_class_attribute(self):
1.70 - self.set("__class__", self)
1.71 + pass
1.72
1.73 class CommonClass(Class):
1.74
1.75 "An inspected class."
1.76
1.77 - def initialise_class_attribute(self):
1.78 - self.set("__class__", type_class)
1.79 + pass
1.80
1.81 class Function(NamespaceDict, Naming, Constant):
1.82