bt2: value.py: refactor value comparison
Changed:
* Remove _spec_eq() methods: each class implements its own __eq__()
method directly.
* Do not use native_bt.value_compare(): we never reached that, because
container value classes (`ArrayValue` and `MapValue`) implement their
own rich, recursive comparison.
* In _NumericValue._extract_value(), do not check the `_NumericValue`,
`False`, and `True` special case: check for `BoolValue` and `bool` to
return a boolean object in those cases.
* In NumericValue.__lt__() and NumericValue.__eq__(), do not check that
the parameter is a number object: self._extract_value() does this
already.
* In BoolValue._value_to_bool(), return the boolean value directly,
not using int(): it's already an integral number.
* In ArrayValue.__eq__(), be more strict: expect that the parameter is
a sequence object, not just an iterable object. Before this, it was
possible to compare an array value to an ordered dict with keys equal
to the array value content, and this seems wrong as:
collections.OrderedDict((('A', 23), ('B', 42))) == ['A', 'B']
is false. An ordered dict is not a sequence.
* In MapValue.__eq__(), be more strict: expect that the parameter is a
mapping object, not just an iterable and indexable object. The reason
is similar to the ArrayValue.__eq__() case above. This should be
enough to compare to another map value or to a dict (or ordered dict).
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I9941d2d82942e2efa8d5380c8ff5a4a2d2cb3a84
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1563
Tested-by: jenkins <jenkins@lttng.org>
This page took 0.025242 seconds and 4 git commands to generate.