qapi: Improve 'include' error message

Use of '"...%s" % include' to print non-strings can lead to
ugly messages, such as this (if the .json change is applied
without the qapi.py change):
 Expected a file name (string), got: OrderedDict()

Better is to just omit the actual non-string value in the
message.

Backports commit 7408fb67c0f9403f6e40aecf97cf798fc14e2cd8 from qemu
This commit is contained in:
Eric Blake 2018-02-19 17:55:32 -05:00 committed by Lioncash
parent 02e411f666
commit de2b67e528
No known key found for this signature in database
GPG Key ID: 4E3C3CC1031BA9C7

View File

@ -132,8 +132,7 @@ class QAPISchemaParser(object):
include = expr["include"] include = expr["include"]
if not isinstance(include, str): if not isinstance(include, str):
raise QAPIExprError(expr_info, raise QAPIExprError(expr_info,
'Expected a file name (string), got: %s' "Value of 'include' must be a string")
% include)
incl_abs_fname = os.path.join(os.path.dirname(abs_fname), incl_abs_fname = os.path.join(os.path.dirname(abs_fname),
include) include)
# catch inclusion cycle # catch inclusion cycle