From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40531) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c7gES-0003vm-7T for qemu-devel@nongnu.org; Fri, 18 Nov 2016 05:17:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c7gEP-0004bo-3h for qemu-devel@nongnu.org; Fri, 18 Nov 2016 05:17:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54390) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c7gEO-0004bL-R8 for qemu-devel@nongnu.org; Fri, 18 Nov 2016 05:17:17 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C62048123E for ; Fri, 18 Nov 2016 10:17:15 +0000 (UTC) From: Markus Armbruster References: <20161117155504.21843-1-marcandre.lureau@redhat.com> <20161117155504.21843-13-marcandre.lureau@redhat.com> Date: Fri, 18 Nov 2016 11:17:13 +0100 In-Reply-To: <20161117155504.21843-13-marcandre.lureau@redhat.com> (=?utf-8?Q?=22Marc-Andr=C3=A9?= Lureau"'s message of "Thu, 17 Nov 2016 19:54:59 +0400") Message-ID: <87eg29jdna.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v5 12/17] qapi: rename QAPIExprError/QAPILineError List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Cc: qemu-devel@nongnu.org Make the summary line "qapi: Rename QAPIExprError to QAPILineError". Marc-Andr=C3=A9 Lureau writes: > There is nothing specific about expressions in this exception, > the following patch will use it without expressions. > > Signed-off-by: Marc-Andr=C3=A9 Lureau > --- > 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) >=20=20 >=20=20 > -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 =3D expr_info > + assert info > + self.info =3D info > self.msg =3D msg >=20=20 > 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 =3D fname self.line =3D line self.col =3D col self.info =3D incl_info self.msg =3D msg def __str__(self): loc =3D "%s:%d" % (self.fname, self.line) if self.col is not None: loc +=3D ":%s" % self.col return error_path(self.info) + \ "%s: %s" % (loc, self.msg) class QAPISchemaParseError(QAPISchemaError): def __init__(self, parser, msg): col =3D 1 for ch in parser.src[parser.line_pos:parser.pos]: if ch =3D=3D '\t': col =3D (col + 7) % 8 + 1 else: col +=3D 1 QAPISchemaError.__init__(self, parser.fname, parser.line, parse= r.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? [...]