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))
|
% (source, all_names[value], orig_value))
|
||||||
return
|
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:
|
if not allow_dict:
|
||||||
raise QAPIExprError(expr_info,
|
raise QAPIExprError(expr_info,
|
||||||
"%s should be a type name" % source)
|
"%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():
|
for (key, arg) in value.items():
|
||||||
check_name(expr_info, "Member of %s" % source, key,
|
check_name(expr_info, "Member of %s" % source, key,
|
||||||
allow_optional=allow_optional)
|
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',
|
{ 'command': 'foo',
|
||||||
'data': false }
|
'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',
|
{ 'struct': 'foo',
|
||||||
'data': false }
|
'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',
|
{ 'struct': 'foo',
|
||||||
'data': { 'a': false } }
|
'data': { 'a': false } }
|
||||||
|
Loading…
Reference in New Issue
Block a user