From: Markus Armbruster <armbru@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v5 12/17] qapi: rename QAPIExprError/QAPILineError
Date: Fri, 18 Nov 2016 11:17:13 +0100 [thread overview]
Message-ID: <87eg29jdna.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <20161117155504.21843-13-marcandre.lureau@redhat.com> ("Marc-André Lureau"'s message of "Thu, 17 Nov 2016 19:54:59 +0400")
Make the summary line "qapi: Rename QAPIExprError to QAPILineError".
Marc-André Lureau <marcandre.lureau@redhat.com> writes:
> There is nothing specific about expressions in this exception,
> the following patch will use it without expressions.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> scripts/qapi.py | 146 ++++++++++++++++++++++++++++----------------------------
> 1 file changed, 73 insertions(+), 73 deletions(-)
>
> diff --git a/scripts/qapi.py b/scripts/qapi.py
> index 21bc32f..4d1b0e4 100644
> --- a/scripts/qapi.py
> +++ b/scripts/qapi.py
> @@ -110,11 +110,11 @@ class QAPISchemaError(Exception):
> "%s:%d:%d: %s" % (self.fname, self.line, self.col, self.msg)
>
>
> -class QAPIExprError(Exception):
> - def __init__(self, expr_info, msg):
> +class QAPILineError(Exception):
> + def __init__(self, info, msg):
> Exception.__init__(self)
> - assert expr_info
> - self.info = expr_info
> + assert info
> + self.info = info
> self.msg = msg
>
> def __str__(self):
Since we're talking about misnamed / awkward error stuff:
* QAPISchemaError is really a parse error. __init__()'s schema argument
isn't a QAPISchema, it's a QAPISchemaParser.
* Method __str__() is mostly duplicated.
How do you like the following untested sketch?
class QAPISchemaError(Exception):
def __init__(self, fname, line, col, incl_info, msg):
Exception.__init__(self)
self.fname = fname
self.line = line
self.col = col
self.info = incl_info
self.msg = msg
def __str__(self):
loc = "%s:%d" % (self.fname, self.line)
if self.col is not None:
loc += ":%s" % self.col
return error_path(self.info) + \
"%s: %s" % (loc, self.msg)
class QAPISchemaParseError(QAPISchemaError):
def __init__(self, parser, msg):
col = 1
for ch in parser.src[parser.line_pos:parser.pos]:
if ch == '\t':
col = (col + 7) % 8 + 1
else:
col += 1
QAPISchemaError.__init__(self, parser.fname, parser.line, parser.col,
parser.incl_info, msg)
class QAPISchemaSemanticError(Exception):
def __init__(self, info, msg):
QAPISchemaError(self, info['file'], info['line'], None,
info['parent'], msg)
The class names are a bit long. If they result in awkward line breaks,
let's shorten them some.
The "except (QAPISchemaError, QAPIExprError)" become just "except
QAPISchemaError".
Could QAPISchemaParser.__init__() raise QAPISchemaParseError instead?
[...]
next prev parent reply other threads:[~2016-11-18 10:17 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-17 15:54 [Qemu-devel] [PATCH v5 00/17] qapi doc generation (whole version, squashed) Marc-André Lureau
2016-11-17 15:54 ` [Qemu-devel] [PATCH v5 01/17] qapi: improve device_add schema Marc-André Lureau
2016-11-17 17:38 ` Markus Armbruster
2016-11-17 19:49 ` Eric Blake
2016-11-17 15:54 ` [Qemu-devel] [PATCH v5 02/17] qga/schema: fix double-return in doc Marc-André Lureau
2016-11-17 17:38 ` Markus Armbruster
2016-11-17 15:54 ` [Qemu-devel] [PATCH v5 03/17] qga/schema: improve guest-set-vcpus Returns: section Marc-André Lureau
2016-11-17 17:39 ` Markus Armbruster
2016-11-18 8:49 ` Marc-André Lureau
2016-11-18 14:07 ` Markus Armbruster
2016-11-17 15:54 ` [Qemu-devel] [PATCH v5 04/17] qapi: fix schema symbol sections Marc-André Lureau
2016-11-17 17:39 ` Markus Armbruster
2016-11-17 15:54 ` [Qemu-devel] [PATCH v5 05/17] qapi: fix missing symbol @prefix Marc-André Lureau
2016-11-17 17:40 ` Markus Armbruster
2016-11-17 15:54 ` [Qemu-devel] [PATCH v5 06/17] qapi: fix various symbols mismatch in documentation Marc-André Lureau
2016-11-17 17:40 ` Markus Armbruster
2016-11-17 15:54 ` [Qemu-devel] [PATCH v5 07/17] qapi: use one symbol per line Marc-André Lureau
2016-11-17 17:40 ` Markus Armbruster
2016-11-17 15:54 ` [Qemu-devel] [PATCH v5 08/17] qapi: add missing colon-ending for section name Marc-André Lureau
2016-11-17 17:41 ` Markus Armbruster
2016-11-17 15:54 ` [Qemu-devel] [PATCH v5 09/17] qapi: add some sections in docs Marc-André Lureau
2016-11-17 17:43 ` Markus Armbruster
2016-11-30 15:38 ` Markus Armbruster
2016-11-30 16:07 ` Marc-André Lureau
2016-11-17 15:54 ` [Qemu-devel] [PATCH v5 10/17] qapi: improve TransactionAction doc Marc-André Lureau
2016-11-17 18:03 ` Markus Armbruster
2016-11-17 15:54 ` [Qemu-devel] [PATCH v5 11/17] docs: add master qapi texi files Marc-André Lureau
2016-11-18 9:09 ` Markus Armbruster
2016-11-17 15:54 ` [Qemu-devel] [PATCH v5 12/17] qapi: rename QAPIExprError/QAPILineError Marc-André Lureau
2016-11-18 10:17 ` Markus Armbruster [this message]
2016-11-18 10:31 ` Marc-André Lureau
2016-11-18 14:13 ` Markus Armbruster
2016-11-17 15:55 ` [Qemu-devel] [PATCH v5 13/17] qapi: add qapi2texi script Marc-André Lureau
2016-11-30 16:06 ` Markus Armbruster
2016-12-05 17:35 ` Marc-André Lureau
2016-12-06 11:50 ` Markus Armbruster
2016-12-06 13:07 ` Marc-André Lureau
2016-12-07 16:05 ` Markus Armbruster
2016-11-17 15:55 ` [Qemu-devel] [PATCH v5 14/17] texi2pod: learn quotation, deftp and deftypefn Marc-André Lureau
2016-11-17 15:55 ` [Qemu-devel] [PATCH v5 15/17] (SQUASHED) move doc to schema Marc-André Lureau
2016-11-17 15:55 ` [Qemu-devel] [PATCH v5 16/17] docs: add qemu logo Marc-André Lureau
2016-11-18 12:52 ` Markus Armbruster
2016-11-21 10:50 ` Marc-André Lureau
2016-11-21 12:07 ` Markus Armbruster
2016-11-17 15:55 ` [Qemu-devel] [PATCH v5 17/17] build-sys: add qapi doc generation targets Marc-André Lureau
2016-11-18 12:31 ` Markus Armbruster
2016-11-21 12:30 ` Marc-André Lureau
2016-12-05 16:53 ` [Qemu-devel] [PATCH v5 00/17] qapi doc generation (whole version, squashed) Markus Armbruster
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=87eg29jdna.fsf@dusky.pond.sub.org \
--to=armbru@redhat.com \
--cc=marcandre.lureau@redhat.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.