From 88d393137acf702d11aee0de515dc8688b9afc07 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Fri, 28 Jun 2019 00:02:01 -0400 Subject: [PATCH] bt2: make `BoolValue` inherit `_IntegralValue` This is just like issubclass(bool, numbers.Integral) issubclass(bool, int) are true. It makes `BoolValue` behave even more like `bool`, for example you can now do: 3 << bt2.BoolValue(True) (which is 6). Also remove BoolValue.__eq__() because _NumericValue.__eq__() does the job now. Signed-off-by: Philippe Proulx Change-Id: Icbcd8d41b9f064c77586e0b7bfdf4a772c15f0f7 Reviewed-on: https://review.lttng.org/c/babeltrace/+/1565 Tested-by: jenkins Reviewed-by: Simon Marchi --- src/bindings/python/bt2/bt2/value.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/bindings/python/bt2/bt2/value.py b/src/bindings/python/bt2/bt2/value.py index 7f003c2b..9cdad357 100644 --- a/src/bindings/python/bt2/bt2/value.py +++ b/src/bindings/python/bt2/bt2/value.py @@ -285,7 +285,7 @@ class _RealValue(_NumericValue, numbers.Real): pass -class BoolValue(_Value): +class BoolValue(_IntegralValue): _NAME = 'Boolean' def __init__(self, value=None): @@ -297,12 +297,6 @@ class BoolValue(_Value): self._check_create_status(ptr) super().__init__(ptr) - def __eq__(self, other): - try: - return self._value == self._value_to_bool(other) - except: - return False - def __bool__(self): return self._value -- 2.34.1