提交 7408fb67 编写于 作者: E Eric Blake 提交者: Markus Armbruster

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.
Signed-off-by: NEric Blake <eblake@redhat.com>
Message-Id: <1443565276-4535-3-git-send-email-eblake@redhat.com>
Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
上级 1ffe818a
......@@ -132,8 +132,7 @@ class QAPISchemaParser(object):
include = expr["include"]
if not isinstance(include, str):
raise QAPIExprError(expr_info,
'Expected a file name (string), got: %s'
% include)
"Value of 'include' must be a string")
incl_abs_fname = os.path.join(os.path.dirname(abs_fname),
include)
# catch inclusion cycle
......
tests/qapi-schema/include-non-file.json:1: Expected a file name (string), got: ['foo', 'bar']
tests/qapi-schema/include-non-file.json:1: Value of 'include' must be a string
{ 'include': [ 'foo', 'bar' ] }
{ 'include': {} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册