From e5e6a30af8f0ac9dd05710520010b810cd47beb9 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Tue, 24 Sep 2019 14:38:51 -0400 Subject: [PATCH] bt2: print actual and expected lengths in _StaticArrayField._set_value error message I think it can help the user figure out what's wrong if we give the lengths of the field and the passed value in the error message. Change-Id: I94fb7ca04724d5d7af701df88aaedc195b1736fd Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/2088 Reviewed-by: Francis Deslauriers --- src/bindings/python/bt2/bt2/field.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bindings/python/bt2/bt2/field.py b/src/bindings/python/bt2/bt2/field.py index fbe609ee..275d500d 100644 --- a/src/bindings/python/bt2/bt2/field.py +++ b/src/bindings/python/bt2/bt2/field.py @@ -855,7 +855,11 @@ class _StaticArrayField(_StaticArrayFieldConst, _ArrayField, _Field): def _set_value(self, values): if len(self) != len(values): - raise ValueError('expected length of value and array field to match') + raise ValueError( + 'expected length of value ({}) and array field ({}) to match'.format( + len(values), len(self) + ) + ) for index, value in enumerate(values): if value is not None: -- 2.34.1