Skip to content

Commit 41525eb

Browse files
Rémy Noeljelly
authored andcommitted
varlink/scanner.py: early exit in case of invalid dict.
No behaviour change since the scanner would end up returning InvalidParam anyway after exhausting all other possible types.
1 parent aaa3ff5 commit 41525eb

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

varlink/scanner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def filter_params(self, parent_name, varlink_type, _namespaced, args, kwargs):
291291
)
292292
return args
293293
else:
294-
InvalidParameter(parent_name)
294+
raise InvalidParameter(parent_name)
295295

296296
if isinstance(varlink_type, _CustomType):
297297
# print("CustomType", varlink_type.name)

varlink/tests/test_scanner.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,14 @@ def test_bad_types(self):
126126
interface = varlink.Interface("""
127127
interface org.example.testerrors
128128
type TypeEnum ( a, b, c )
129+
type TypeDict (dict: [string]string)
129130
130131
method Foo(param: TypeEnum) -> ()
132+
method Bar(param: TypeDict) -> ()
131133
""")
132134
foo = interface.get_method("Foo")
133135
with self.assertRaises(varlink.InvalidParameter):
134136
interface.filter_params("test.call", foo.in_type, False, (), {"param": "d"})
137+
bar = interface.get_method("Bar")
138+
with self.assertRaises(varlink.InvalidParameter):
139+
interface.filter_params("test.call", bar.in_type, False, (), {"param": {"dict": [1, 2, 3]}})

0 commit comments

Comments
 (0)