# HG changeset patch # User Paul Boddie # Date 1232227999 -3600 # Node ID d213a26b1846790bd50dc66510f161691b15bff2 # Parent 839a5b14e2636769b17a9608515ed6520ff3d255 Insist on Const instances as keys for the constants dictionary, ensuring that distinct values are recognised, particularly True and 1, False and 0. diff -r 839a5b14e263 -r d213a26b1846 micropython/__init__.py --- a/micropython/__init__.py Fri Jan 16 00:52:04 2009 +0100 +++ b/micropython/__init__.py Sat Jan 17 22:33:19 2009 +0100 @@ -499,16 +499,17 @@ "Return a constant for the given 'value'." - return self.constant_values[value] + const = micropython.data.Const(value) + return self.constant_values[const] def make_constant(self, value): "Make and return a constant for the given 'value'." - if not self.constant_values.has_key(value): - const = micropython.data.Const(value) - self.constant_values[value] = const - return self.constant_values[value] + const = micropython.data.Const(value) + if not self.constant_values.has_key(const): + self.constant_values[const] = const + return self.constant_values[const] def constants(self): diff -r 839a5b14e263 -r d213a26b1846 micropython/data.py --- a/micropython/data.py Fri Jan 16 00:52:04 2009 +0100 +++ b/micropython/data.py Sat Jan 17 22:33:19 2009 +0100 @@ -349,7 +349,7 @@ # Support constants as dictionary keys in order to build constant tables. def __eq__(self, other): - return self.value == other.value + return self.value == other.value and self.value.__class__ is other.value.__class__ def __hash__(self): return hash(self.value)