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)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 3 Jul 2019 01:31:27 +0000 (21:31 -0400)
commite502b15acf555af2b6f5c43c1ab1876e816c45f9
tree437ed0654eeb4f5fe16eaae70edae370308dd2d4
parentda911a377b4b4840a0a9b9d654df01fc2a8f94d5
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.02463 seconds and 4 git commands to generate.