From 81cf8fa8269867ad221e99cfe34ec4e102d4071d Mon Sep 17 00:00:00 2001 From: Joshua Lock Date: Mon, 6 Jan 2020 10:58:59 +0000 Subject: [PATCH] Make check_match() errors more readable for ListOf objects When the ListOf object's check_match() fails due to an incompatible object having been passed, the salient information for the error message is the type of the passed object and the type of the object against which the check_match() method was called, therefore print those types in the error message and not the string representation of the objects. Fixes #194 Signed-off-by: Joshua Lock --- securesystemslib/schema.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/securesystemslib/schema.py b/securesystemslib/schema.py index 8049c5c4..1eb48137 100755 --- a/securesystemslib/schema.py +++ b/securesystemslib/schema.py @@ -523,7 +523,8 @@ def __init__(self, schema, min_count=0, max_count=sys.maxsize, list_name='list') def check_match(self, object): if not isinstance(object, (list, tuple)): raise securesystemslib.exceptions.FormatError( - 'Expected ' + repr(self._list_name) + ' but got ' + repr(object)) + 'Expected object of type {} but got type {}'.format( + self._list_name, type(object).__name__)) # Check if all the items in the 'object' list