[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH RFC 11/21] qapi: Lift error reporting from QAPIS
From: |
Marc-Andre Lureau |
Subject: |
Re: [Qemu-devel] [PATCH RFC 11/21] qapi: Lift error reporting from QAPISchema.__init__() to callers |
Date: |
Mon, 5 Feb 2018 14:45:08 +0100 |
On Fri, Feb 2, 2018 at 2:03 PM, Markus Armbruster <address@hidden> wrote:
> Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
> ---
> scripts/qapi-gen.py | 8 ++++++--
> scripts/qapi/common.py | 23 +++++++++--------------
> tests/qapi-schema/test-qapi.py | 8 +++++++-
> 3 files changed, 22 insertions(+), 17 deletions(-)
>
> diff --git a/scripts/qapi-gen.py b/scripts/qapi-gen.py
> index 6302fd0d55..ba82ca92cc 100755
> --- a/scripts/qapi-gen.py
> +++ b/scripts/qapi-gen.py
> @@ -7,7 +7,7 @@
> import getopt
> import re
> import sys
> -from qapi.common import QAPISchema
> +from qapi.common import QAPIError, QAPISchema
> from qapi.types import gen_types
> from qapi.visit import gen_visit
> from qapi.commands import gen_commands
> @@ -77,7 +77,11 @@ def main(argv):
> if o in ('-u', '--unmask-non-abi-names'):
> opt_unmask = True
>
> - schema = QAPISchema(input_file)
> + try:
> + schema = QAPISchema(input_file)
> + except QAPIError as err:
> + print >>sys.stderr, err
> + exit(1)
>
> gen_types(schema, output_dir, prefix, opt_builtins)
> gen_visit(schema, output_dir, prefix, opt_builtins)
> diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
> index 78e960d07c..d334e1db5a 100644
> --- a/scripts/qapi/common.py
> +++ b/scripts/qapi/common.py
> @@ -15,7 +15,6 @@ import errno
> import os
> import re
> import string
> -import sys
> from ordereddict import OrderedDict
>
> builtin_types = {
> @@ -1455,19 +1454,15 @@ class QAPISchemaEvent(QAPISchemaEntity):
>
> class QAPISchema(object):
> def __init__(self, fname):
> - try:
> - parser = QAPISchemaParser(open(fname, 'r'))
> - exprs = check_exprs(parser.exprs)
> - self.docs = parser.docs
> - self._entity_dict = {}
> - self._predefining = True
> - self._def_predefineds()
> - self._predefining = False
> - self._def_exprs(exprs)
> - self.check()
> - except QAPIError as err:
> - print >>sys.stderr, err
> - exit(1)
> + parser = QAPISchemaParser(open(fname, 'r'))
> + exprs = check_exprs(parser.exprs)
> + self.docs = parser.docs
> + self._entity_dict = {}
> + self._predefining = True
> + self._def_predefineds()
> + self._predefining = False
> + self._def_exprs(exprs)
> + self.check()
>
> def _def_entity(self, ent):
> # Only the predefined types are allowed to not have info
> diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py
> index 7772d09919..d6bb8ec6a4 100644
> --- a/tests/qapi-schema/test-qapi.py
> +++ b/tests/qapi-schema/test-qapi.py
> @@ -53,7 +53,13 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor):
> for v in variants.variants:
> print ' case %s: %s' % (v.name, v.type.name)
>
> -schema = QAPISchema(sys.argv[1])
> +
> +try:
> + schema = QAPISchema(sys.argv[1])
> +except QAPIError as err:
> + print >>sys.stderr, err
> + exit(1)
> +
> schema.visit(QAPISchemaTestVisitor())
>
> for doc in schema.docs:
> --
> 2.13.6
>
- [Qemu-devel] [PATCH RFC 07/21] qapi: Move parse_command_line() next to its only use, (continued)
- [Qemu-devel] [PATCH RFC 07/21] qapi: Move parse_command_line() next to its only use, Markus Armbruster, 2018/02/02
- [Qemu-devel] [PATCH RFC 19/21] qapi/types: Generate separate .h, .c for each module, Markus Armbruster, 2018/02/02
- [Qemu-devel] [PATCH RFC 01/21] qapi: Streamline boilerplate comment generation, Markus Armbruster, 2018/02/02
- [Qemu-devel] [PATCH RFC 11/21] qapi: Lift error reporting from QAPISchema.__init__() to callers, Markus Armbruster, 2018/02/02
- Re: [Qemu-devel] [PATCH RFC 11/21] qapi: Lift error reporting from QAPISchema.__init__() to callers,
Marc-Andre Lureau <=
- [Qemu-devel] [PATCH RFC 21/21] qapi: Empty out qapi-schema.json, Markus Armbruster, 2018/02/02
- [Qemu-devel] [PATCH RFC 04/21] qapi: Reduce use of global variables in generators some, Markus Armbruster, 2018/02/02
- [Qemu-devel] [PATCH RFC 18/21] qapi/common: Fix guardname() for funny filenames, Markus Armbruster, 2018/02/02
- [Qemu-devel] [PATCH RFC 12/21] qapi: Concentrate QAPISchemaParser.exprs updates in .__init__(), Markus Armbruster, 2018/02/02