]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
qapi: Improve 'include' error message
authorEric Blake <eblake@redhat.com>
Tue, 29 Sep 2015 22:21:00 +0000 (16:21 -0600)
committerMarkus Armbruster <armbru@redhat.com>
Mon, 12 Oct 2015 16:44:54 +0000 (18:44 +0200)
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: Eric Blake <eblake@redhat.com>
Message-Id: <1443565276-4535-3-git-send-email-eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
scripts/qapi.py
tests/qapi-schema/include-non-file.err
tests/qapi-schema/include-non-file.json

index 06478bb269d81758543bd9c0d08d5a9afb637d7e..362e0076e99b1c9b3eeffd7124fd3b74b2aaa381 100644 (file)
@@ -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
index 9658c788012cd7298a17b92e19006c38b5b51e60..faae1eacf1aa2e5412393a16456ff7d97cb0850f 100644 (file)
@@ -1 +1 @@
-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
index cd43c3f9dbcfb020d538c92296b571a0a7e994d8..4711aa42e58c1d31355b5ed8fe2a81aab28ee2bd 100644 (file)
@@ -1 +1 @@
-{ 'include': [ 'foo', 'bar' ] }
+{ 'include': {} }