bt2: field.py: _value_to_int(): require `numbers.Integral`
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 28 Jun 2019 05:08:25 +0000 (01:08 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 3 Jul 2019 01:31:27 +0000 (21:31 -0400)
commit25bb9babab83dac379726dc2de47f6023a3834e9
tree8553c3c29ba5946cd186c7f7e0322e9cabdbb700
parent3dc0614bb91af3ef70b5f5414318e5f2e052e582
bt2: field.py: _value_to_int(): require `numbers.Integral`

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

    my_int_field.value = 17.5

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

RealValue._value_to_float() already requires a real value, so this is
just analogous.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: I3b981e90f7e2c133fa4d56e79333c4fe600eca8b
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1569
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/field.py
tests/bindings/python/bt2/test_field.py
This page took 0.024388 seconds and 4 git commands to generate.