From f6cfe9803ca743c6b9a17d72629a3553f30a04e5 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 10 Feb 2023 14:01:57 +1000 Subject: [PATCH] scanner: make the invalid type message a bit easier to identify --- proto/scanner.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/proto/scanner.py b/proto/scanner.py index 355ed29..83ac6d1 100755 --- a/proto/scanner.py +++ b/proto/scanner.py @@ -112,8 +112,9 @@ class Argument: @signature.validator # type: ignore def _validate_signature(self, attribute, value): - types = "iufhnos" - assert value in types, f"Failed to parse signature {value}" + assert ( + value is not None and value in "iufhnos" + ), f"Failed to parse signature {value}" @classmethod def create( @@ -124,7 +125,13 @@ class Argument: enum: Optional["Enum"] = None, interface: Optional["Interface"] = None, ) -> "Argument": - return cls(name, signature, summary, enum, interface=interface) + return cls( + name=name, + signature=signature, + summary=summary, + enum=enum, + interface=interface, + ) @attr.s @@ -499,6 +506,12 @@ class Protocol(xml.sax.handler.ContentHandler): ) name = attrs["name"] sig = attrs["type"] + if proto_to_type(sig) is None: + raise XmlError( + *self.location, + f"Invalid type '{sig}' for '{self.current_interface.name}.{self.current_message.name}::{name}'", + ) + summary = attrs.get("summary", "") interface_name = attrs.get("interface", None) if interface_name is not None: