qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v12 4/4] qapi: Add a primitive to include other


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH v12 4/4] qapi: Add a primitive to include other files from a QAPI schema file
Date: Sun, 18 May 2014 12:44:24 +0100

On 7 May 2014 19:46, Lluís Vilanova <address@hidden> wrote:
> The primitive uses JSON syntax, and include paths are relative to the file 
> using the directive:
>
>   { 'include': 'path/to/file.json' }
>
> Signed-off-by: Lluís Vilanova <address@hidden>
> Reviewed-by: Eric Blake <address@hidden>
> Reviewed-by: Markus Armbruster <address@hidden>

> @@ -74,10 +91,33 @@ class QAPISchema:
>          self.accept()
>
>          while self.tok != None:
> -            expr_info = {'fp': fp, 'line': self.line}
> -            expr_elem = {'expr': self.get_expr(False),
> -                         'info': expr_info}
> -            self.exprs.append(expr_elem)
> +            expr_info = {'file': input_relname, 'line': self.line, 'parent': 
> self.parent_info}
> +            expr = self.get_expr(False)
> +            if isinstance(expr, dict) and "include" in expr:
> +                if len(expr) != 1:
> +                    raise QAPIExprError(expr_info, "Invalid 'include' 
> directive")
> +                include = expr["include"]
> +                if not isinstance(include, str):
> +                    raise QAPIExprError(expr_info,
> +                                        'Expected a file name (string), got: 
> %s'
> +                                        % include)
> +                include_path = os.path.join(self.input_dir, include)
> +                if any(include_path == elem[1]
> +                       for elem in self.include_hist):
> +                    raise QAPIExprError(expr_info, "Inclusion loop for %s"
> +                                        % include)
> +                try:
> +                    fobj = open(include_path, 'r')
> +                except IOError as e:

Hi. I'm afraid "except ... as" is only supported in Python 2.6,
and we have to support Python 2.4 still (as Andreas mentioned
in another thread this breaks compilation on MacOSX 10.5).
Please can you fix this to use the older syntax (cf also commit
21e0043bad which fixed an earlier instance of this problem)?

thanks
-- PMM



reply via email to

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