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)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 18 Jul 2019 15:53:33 +0000 (11:53 -0400)
commite2cf9726bee31cde5c089095438e4e5e89cb5e09
treebccf6b19dc66d76c4de3887b1b5473a8997fa2b9
parenta26968bfbc2a8ea7f5cd175ff0dcb3fb78379287
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.025298 seconds and 4 git commands to generate.