bt2: field.py: refactor field comparison
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 28 Jun 2019 03:54:08 +0000 (23:54 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 18 Jul 2019 15:53:33 +0000 (11:53 -0400)
commit0bde7b52185afa41f068295d5c27851450dddd5f
tree1f0ecb8903114be424bac4c1ddb42b5034401e75
parentcfc3ccc1864e09c59eb5b2efa9dce27a07b7d704
bt2: field.py: refactor field comparison

Changed:

* In _NumericField._extract_value(), do not check the `False`, and
  `True` special cases: check that the parameter is an instance of the
  `bool` type to return a boolean object.

* In _ArrayField.__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 field to an ordered dict with keys equal
  to the array field content, and this seems wrong as:

      collections.OrderedDict((('A', 23), ('B', 42))) == ['A', 'B']

  is false. An ordered dict is not a sequence.

* In _StructureField.__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 _ArrayField.__eq__() case above. This should
  be enough to compare to another structure field or to a dict (or
  ordered dict).

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I17f33c24e9dea526e59b5058235d57facb51cfbf
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1564
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
src/bindings/python/bt2/bt2/field.py
This page took 0.024741 seconds and 4 git commands to generate.