qemu-devel
[Top][All Lists]
Advanced

[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
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]