bt2: value.py: _IntegerValue._value_to_int(): require `numbers.Integral`
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 28 Jun 2019 04:44:04 +0000 (00:44 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 18 Jul 2019 15:53:33 +0000 (11:53 -0400)
commit5100844da090f03ef0c23a195b310dcef9643fc5
tree1d49b0947461143ceb65ac48a990b110fcff945d
parentd79a9f23979db0b733be95e4b56da3911e56c0a9
bt2: value.py: _IntegerValue._value_to_int(): require `numbers.Integral`

Be more strict in _IntegerValue._value_to_int(): require that the
parameter's type is an instance of `numbers.Integral` instead of
`numbers.Real` to make the following raise a type error:

    bt2.UnsignedIntegerValue(17.5)

and

    a = bt2.UnsignedIntegerValue()
    a.value = 17.5

I believe it's better to be strict here than to arbitrarily choose to
use the parameter's value's floor.

BoolValue._value_to_bool() and RealValue._value_to_float() already
require resp. a boolean value and a real value, so this is just
analogous.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I374baf8c5d69400b687daabea873598eb2543a47
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1567
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Reviewed-by: Simon Marchi <simon.marchi@efficios.com>
src/bindings/python/bt2/bt2/value.py
tests/bindings/python/bt2/test_value.py
This page took 0.026945 seconds and 4 git commands to generate.