1.1 --- a/micropython/data.py Mon Jul 04 23:50:02 2011 +0200
1.2 +++ b/micropython/data.py Tue Jul 05 00:36:54 2011 +0200
1.3 @@ -236,6 +236,10 @@
1.4 assignments in the lifetime of a program).
1.5 """
1.6
1.7 + if value is None:
1.8 + print "Warning: name %r in namespace %r has an unknown value (evaluated to None)." % (name, self.full_name())
1.9 + value = Instance()
1.10 +
1.11 if name in self.globals:
1.12 self.module.set(name, value, 0)
1.13 else:
1.14 @@ -928,11 +932,15 @@
1.15 many assignments may be involved.
1.16 """
1.17
1.18 + if self.context_values.issuperset(context_values) and \
1.19 + not (Instance(), Instance()) in context_values:
1.20 + return
1.21 +
1.22 if self.assignments is None:
1.23 if single_assignment:
1.24 - self.assignments = 1
1.25 + self.assignments = len(set(context_values))
1.26 else:
1.27 - self.assignments = AtLeast(1)
1.28 + self.assignments = AtLeast(len(set(context_values)))
1.29 else:
1.30 if single_assignment:
1.31 self.assignments += 1
1.32 @@ -1079,6 +1087,15 @@
1.33 def __repr__(self):
1.34 return "Instance()"
1.35
1.36 + def __eq__(self, other):
1.37 + return other.__class__ is Instance
1.38 +
1.39 + def __ne__(self, other):
1.40 + return not self.__eq__(other)
1.41 +
1.42 + def __hash__(self):
1.43 + return 0
1.44 +
1.45 __shortrepr__ = __repr__
1.46
1.47 class Constant:
1.48 @@ -1111,7 +1128,11 @@
1.49 # Support constants as dictionary keys in order to build constant tables.
1.50
1.51 def __eq__(self, other):
1.52 - return other is not None and self.value == other.value and self.value.__class__ is other.value.__class__
1.53 + return other is not None and isinstance(other, Const) and \
1.54 + self.value == other.value and self.value.__class__ is other.value.__class__
1.55 +
1.56 + def __ne__(self, other):
1.57 + return not self.__eq__(other)
1.58
1.59 def __hash__(self):
1.60 return hash(self.value)