Fix: bt2: erroneous integer comparison of Field and Value
[babeltrace.git] / src / bindings / python / bt2 / bt2 / value.py
index d8b8332eecd87bd06942ac3a839b0a96c42b5eeb..c5c23fe6783ab9ca018da78a752b2126cc85bd70 100644 (file)
@@ -160,13 +160,6 @@ class _NumericValue(_Value):
 
         return self._value < float(other)
 
-    def __le__(self, other):
-        if not isinstance(other, numbers.Number):
-            raise TypeError('unorderable types: {}() <= {}()'.format(self.__class__.__name__,
-                                                                     other.__class__.__name__))
-
-        return self._value <= float(other)
-
     def _spec_eq(self, other):
         pass
 
@@ -319,6 +312,18 @@ class _IntegralValue(_NumericValue, numbers.Integral):
         self.value = self | other
         return self
 
+    def __lt__(self, other):
+        if not isinstance(other, numbers.Integral):
+            return super().__lt__(other)
+
+        return self._value < int(other)
+
+    def __eq__(self, other):
+        if not isinstance(other, numbers.Integral):
+            return super().__eq__(other)
+
+        return self._value == int(other)
+
 
 class _RealValue(_NumericValue, numbers.Real):
     pass
@@ -475,9 +480,6 @@ class StringValue(collections.abc.Sequence, _Value):
         except:
             return
 
-    def __le__(self, other):
-        return self._value <= self._value_to_str(other)
-
     def __lt__(self, other):
         return self._value < self._value_to_str(other)
 
This page took 0.025215 seconds and 4 git commands to generate.