[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v4 08/19] qapi: Better error messages for bad ex
From: |
Kevin Wolf |
Subject: |
Re: [Qemu-devel] [PATCH v4 08/19] qapi: Better error messages for bad expressions |
Date: |
Wed, 24 Sep 2014 11:25:47 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
Am 24.09.2014 um 09:34 hat Markus Armbruster geschrieben:
> Eric Blake <address@hidden> writes:
>
> > On 09/23/2014 08:56 AM, Markus Armbruster wrote:
> >> Eric Blake <address@hidden> writes:
> >>> Add check_keys to cover these situations, and update testcases to
> >>> match. A couple other tests (enum-missing-data, indented-expr) had
> >>> to change since the validation added here occurs so early.
> >>>
> >>> While valid .json files won't trigger any of these cases, we might
> >>> as well be nicer to developers that make a typo while trying to add
> >>> new QAPI code.
> >>>
> >>> Signed-off-by: Eric Blake <address@hidden>
> >>
> >
> >>> +def check_keys(expr_elem, meta, required, optional=[]):
> >>> + expr = expr_elem['expr']
> >>> + info = expr_elem['info']
> >>> + name = expr[meta]
> >>
> >> Caller ensures expr[meta] exists. Okay.
> >>
> >>> + if not isinstance(name, basestring):
> >>
> >> I'm a Python noob: why basestring and not str?
> >
> > Me too. No clue. Copy and paste from existing code.
> > http://git.qemu.org/?p=qemu.git;a=blob;f=scripts/qapi.py;h=77d46aa;hb=769188d3b#l361
>
> Yes. It's our only use of basestring. Other places use isinstance(FOO,
> str).
>
> The basestring use comes from Kevin's commit b35284e. Kevin, why
> basestring and not str?
Do I look as if I knew what I'm doing when I write Python code? :-)
Apparently basestring is the superclass for ASCII and Unicode strings. I
seem to dimly remember that I did indeed get a Unicode string somewhere
(even though probably no non-ASCII characters in it) and it caused
trouble. Might well have been here.
Kevin
- Re: [Qemu-devel] [PATCH v4 10/19] qapi: Better error messages for duplicated expressions, (continued)
[Qemu-devel] [PATCH v4 04/19] qapi: Document type-safety considerations, Eric Blake, 2014/09/19
[Qemu-devel] [PATCH v4 08/19] qapi: Better error messages for bad expressions, Eric Blake, 2014/09/19
- Re: [Qemu-devel] [PATCH v4 08/19] qapi: Better error messages for bad expressions, Markus Armbruster, 2014/09/23
- Re: [Qemu-devel] [PATCH v4 08/19] qapi: Better error messages for bad expressions, Eric Blake, 2014/09/23
- Re: [Qemu-devel] [PATCH v4 08/19] qapi: Better error messages for bad expressions, Markus Armbruster, 2014/09/24
- Re: [Qemu-devel] [PATCH v4 08/19] qapi: Better error messages for bad expressions,
Kevin Wolf <=
- Re: [Qemu-devel] [PATCH v4 08/19] qapi: Better error messages for bad expressions, Markus Armbruster, 2014/09/24
- Re: [Qemu-devel] [PATCH v4 08/19] qapi: Better error messages for bad expressions, Markus Armbruster, 2014/09/26
- Re: [Qemu-devel] [PATCH v4 08/19] qapi: Better error messages for bad expressions, Kevin Wolf, 2014/09/26
- Re: [Qemu-devel] [PATCH v4 08/19] qapi: Better error messages for bad expressions, Markus Armbruster, 2014/09/26
[Qemu-devel] [PATCH v4 09/19] qapi: Add tests of redefined expressions, Eric Blake, 2014/09/19
[Qemu-devel] [PATCH v4 11/19] qapi: Add tests of type bypass, Eric Blake, 2014/09/19
[Qemu-devel] [PATCH v4 13/19] qapi: More rigourous checking of types, Eric Blake, 2014/09/19