From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: armbru@redhat.com, Michael Roth <mdroth@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH RFC 1/3] qapi: Improve 'include' error message
Date: Thu, 10 Sep 2015 16:25:47 -0600 [thread overview]
Message-ID: <1441923949-3370-2-git-send-email-eblake@redhat.com> (raw)
In-Reply-To: <1441923949-3370-1-git-send-email-eblake@redhat.com>
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>
---
scripts/qapi.py | 4 ++--
tests/qapi-schema/include-non-file.err | 2 +-
tests/qapi-schema/include-non-file.json | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/scripts/qapi.py b/scripts/qapi.py
index a38862d..df06421 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -138,8 +138,8 @@ class QAPISchemaParser(object):
"Invalid 'include' directive")
include = expr["include"]
if not isinstance(include, str):
- raise QAPIExprError(expr_info, 'Expected a file name '
- '(string), got: %s' % include)
+ raise QAPIExprError(expr_info,
+ "Expected a string for 'include'")
incl_abs_fname = os.path.join(os.path.dirname(abs_fname),
include)
# catch inclusion cycle
diff --git a/tests/qapi-schema/include-non-file.err b/tests/qapi-schema/include-non-file.err
index 9658c78..079120b 100644
--- a/tests/qapi-schema/include-non-file.err
+++ b/tests/qapi-schema/include-non-file.err
@@ -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: Expected a string for 'include'
diff --git a/tests/qapi-schema/include-non-file.json b/tests/qapi-schema/include-non-file.json
index cd43c3f..4711aa4 100644
--- a/tests/qapi-schema/include-non-file.json
+++ b/tests/qapi-schema/include-non-file.json
@@ -1 +1 @@
-{ 'include': [ 'foo', 'bar' ] }
+{ 'include': {} }
--
2.4.3
next prev parent reply other threads:[~2015-09-10 22:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-10 22:25 [Qemu-devel] [PATCH RFC 0/3] qapi: more introspection tweaks Eric Blake
2015-09-10 22:25 ` Eric Blake [this message]
2015-09-10 22:25 ` [Qemu-devel] [PATCH RFC 2/3] qapi: Sort qapi-schema tests Eric Blake
2015-09-10 22:25 ` [Qemu-devel] [PATCH RFC 3/3] qapi-introspect: Guarantee particular sorting Eric Blake
2015-09-10 22:59 ` [Qemu-devel] [PATCH RFC 0/3] qapi: more introspection tweaks Eric Blake
2015-09-11 12:01 ` Marc-André Lureau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1441923949-3370-2-git-send-email-eblake@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.