mirror of
https://github.com/qemu/qemu.git
synced 2024-11-24 11:23:43 +08:00
qapi: Fix errors for non-string, non-dictionary members
Fixes the errors demonstrated by the previous commit. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
10689e36eb
commit
c6b71e5ae7
@ -462,13 +462,15 @@ def check_type(expr_info, source, value, allow_array = False,
|
||||
% (source, all_names[value], orig_value))
|
||||
return
|
||||
|
||||
# value is a dictionary, check that each member is okay
|
||||
if not isinstance(value, OrderedDict):
|
||||
raise QAPIExprError(expr_info,
|
||||
"%s should be a dictionary" % source)
|
||||
if not allow_dict:
|
||||
raise QAPIExprError(expr_info,
|
||||
"%s should be a type name" % source)
|
||||
|
||||
if not isinstance(value, OrderedDict):
|
||||
raise QAPIExprError(expr_info,
|
||||
"%s should be a dictionary or type name" % source)
|
||||
|
||||
# value is a dictionary, check that each member is okay
|
||||
for (key, arg) in value.items():
|
||||
check_name(expr_info, "Member of %s" % source, key,
|
||||
allow_optional=allow_optional)
|
||||
|
@ -1 +1 @@
|
||||
tests/qapi-schema/args-invalid.json:2: 'data' for command 'foo' should be a dictionary
|
||||
tests/qapi-schema/args-invalid.json:1: 'data' for command 'foo' should be a dictionary or type name
|
||||
|
@ -1,3 +1,2 @@
|
||||
# FIXME error "should be a dictionary" is misleading, type name is also fine
|
||||
{ 'command': 'foo',
|
||||
'data': false }
|
||||
|
@ -1 +1 @@
|
||||
tests/qapi-schema/struct-data-invalid.json:2: 'data' for struct 'foo' should be a dictionary
|
||||
tests/qapi-schema/struct-data-invalid.json:1: 'data' for struct 'foo' should be a dictionary or type name
|
||||
|
@ -1,3 +1,2 @@
|
||||
# FIXME error "should be a dictionary" is misleading, type name is also fine
|
||||
{ 'struct': 'foo',
|
||||
'data': false }
|
||||
|
@ -1 +1 @@
|
||||
tests/qapi-schema/struct-member-invalid.json:2: Member 'a' of 'data' for struct 'foo' should be a dictionary
|
||||
tests/qapi-schema/struct-member-invalid.json:1: Member 'a' of 'data' for struct 'foo' should be a type name
|
||||
|
@ -1,3 +1,2 @@
|
||||
# FIXME error message "should be a dictionary" is wrong, must be type name
|
||||
{ 'struct': 'foo',
|
||||
'data': { 'a': false } }
|
||||
|
Loading…
Reference in New Issue
Block a user