1.1 --- a/lib/builtins.py Mon Jun 13 20:59:00 2011 +0200
1.2 +++ b/lib/builtins.py Tue Jun 14 01:06:45 2011 +0200
1.3 @@ -35,7 +35,9 @@
1.4 def __init__(self):
1.5 "No-operation."
1.6 pass
1.7 - def __bool__(self): pass
1.8 + def __bool__(self):
1.9 + "Objects are true by default."
1.10 + return True
1.11
1.12 class basestring(object):
1.13 def __init__(self, x=None): pass
1.14 @@ -68,11 +70,11 @@
1.15
1.16 def __le__(self, other):
1.17 "Return a new boolean for the comparison."
1.18 - return not self.__gt__(other)
1.19 + return _negate(self.__gt__(other))
1.20
1.21 def __ge__(self, other):
1.22 "Return a new boolean for the comparison."
1.23 - return not self.__lt__(other)
1.24 + return _negate(self.__lt__(other))
1.25
1.26 def __eq__(self, other):
1.27 "Return a new boolean for the comparison."
1.28 @@ -80,13 +82,13 @@
1.29
1.30 def __ne__(self, other):
1.31 "Return a new boolean for the comparison."
1.32 - return not self.__eq__(other)
1.33 + return _negate(self.__eq__(other))
1.34
1.35 def __len__(self): pass
1.36 def __str__(self): pass
1.37
1.38 def __bool__(self):
1.39 - return not native._str_eq(self, "")
1.40 + return _negate(native._str_eq(self, ""))
1.41
1.42 def join(self, l): pass
1.43 def split(self, s): pass
1.44 @@ -237,11 +239,11 @@
1.45
1.46 def __le__(self, other):
1.47 "Return a new boolean for the comparison."
1.48 - return not self.__gt__(other)
1.49 + return _negate(self.__gt__(other))
1.50
1.51 def __ge__(self, other):
1.52 "Return a new boolean for the comparison."
1.53 - return not self.__lt__(other)
1.54 + return _negate(self.__lt__(other))
1.55
1.56 def __eq__(self, other):
1.57 "Return a new boolean for the comparison."
1.58 @@ -249,7 +251,7 @@
1.59
1.60 def __ne__(self, other):
1.61 "Return a new boolean for the comparison."
1.62 - return not self.__eq__(other)
1.63 + return _negate(self.__eq__(other))
1.64
1.65 def __neg__(self): pass
1.66 def __pos__(self): pass
1.67 @@ -261,7 +263,7 @@
1.68
1.69 def __bool__(self):
1.70 "Return whether this int is non-zero."
1.71 - return not native._int_eq(self, 0)
1.72 + return _negate(native._int_eq(self, 0))
1.73
1.74 class list(object):
1.75
1.76 @@ -673,6 +675,15 @@
1.77 else:
1.78 return NotImplemented
1.79
1.80 +def _negate(result):
1.81 +
1.82 + "Negate any valid logical value."
1.83 +
1.84 + if result is NotImplemented:
1.85 + return result
1.86 + else:
1.87 + return not result
1.88 +
1.89 def _get_absolute_index(index, length):
1.90
1.91 """
1.92 @@ -769,7 +780,7 @@
1.93 AttributeError
1.94 #IndexError
1.95 #NoneType
1.96 -#NotImplementedType
1.97 +NotImplementedType
1.98 #StopIteration
1.99 TypeError
1.100
2.1 --- a/micropython/inspect.py Mon Jun 13 20:59:00 2011 +0200
2.2 +++ b/micropython/inspect.py Tue Jun 14 01:06:45 2011 +0200
2.3 @@ -658,7 +658,6 @@
2.4 # NOTE: this is merely creating aliases for such methods.
2.5
2.6 self.use_specific_attribute(None, node.name)
2.7 -
2.8 return None
2.9
2.10 visitAssTuple = visitAssList
3.1 --- a/tests/compare_equality.py Mon Jun 13 20:59:00 2011 +0200
3.2 +++ b/tests/compare_equality.py Tue Jun 14 01:06:45 2011 +0200
3.3 @@ -14,6 +14,7 @@
3.4 result_1 = 0
3.5 result_2 = 2
3.6 result_3 = 3
3.7 +result_4 = 0
3.8
3.9 if a != x != b:
3.10 result_1 = 1
3.11 @@ -24,4 +25,7 @@
3.12 if a == x:
3.13 result_3 = 0
3.14
3.15 +if a != x:
3.16 + result_4 = 4
3.17 +
3.18 # vim: tabstop=4 expandtab shiftwidth=4