From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44316) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c7gSf-00014m-VA for qemu-devel@nongnu.org; Fri, 18 Nov 2016 05:32:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c7gSa-0002hQ-OZ for qemu-devel@nongnu.org; Fri, 18 Nov 2016 05:32:01 -0500 Received: from mx5-phx2.redhat.com ([209.132.183.37]:37095) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c7gSa-0002hH-FH for qemu-devel@nongnu.org; Fri, 18 Nov 2016 05:31:56 -0500 Date: Fri, 18 Nov 2016 05:31:54 -0500 (EST) From: =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Message-ID: <602698312.296363.1479465114767.JavaMail.zimbra@redhat.com> In-Reply-To: <87eg29jdna.fsf@dusky.pond.sub.org> References: <20161117155504.21843-1-marcandre.lureau@redhat.com> <20161117155504.21843-13-marcandre.lureau@redhat.com> <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: Markus Armbruster Cc: =?utf-8?Q?Marc-Andr=C3=A9?= Lureau , qemu-devel@nongnu.org ----- Original Message ----- > Make the summary line "qapi: Rename QAPIExprError to QAPILineError". >=20 ok > Marc-Andr=C3=A9 Lureau writes: >=20 > > 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.ms= g) > > =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 > > def __str__(self): >=20 > Since we're talking about misnamed / awkward error stuff: >=20 > * QAPISchemaError is really a parse error. __init__()'s schema argument > isn't a QAPISchema, it's a QAPISchemaParser. >=20 > * Method __str__() is mostly duplicated. >=20 > How do you like the following untested sketch? I like it, though I would consider it separately from this series. Here I s= ystematically renamed the existing class ("line" since it's about location = in file), your proposed change has more implications I don't really want to= get into here. >=20 > 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 >=20 > 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) >=20 >=20 > 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, > parser.col, > parser.incl_info, msg) >=20 >=20 > class QAPISchemaSemanticError(Exception): > def __init__(self, info, msg): > QAPISchemaError(self, info['file'], info['line'], None, > info['parent'], msg) >=20 > The class names are a bit long. If they result in awkward line breaks, > let's shorten them some. >=20 > The "except (QAPISchemaError, QAPIExprError)" become just "except > QAPISchemaError". >=20 > Could QAPISchemaParser.__init__() raise QAPISchemaParseError instead? >=20 > [...] >=20