From: John Snow Date: Wed, 19 May 2021 18:39:43 +0000 (-0400) Subject: qapi/parser: assert object keys are strings X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=234dce2c2d93cfff7433c0fd244ef207c7eace2b;p=qemu.git qapi/parser: assert object keys are strings The single quote token implies the value is a string. Assert this to be the case, to allow us to write an accurate return type for get_members. Signed-off-by: John Snow Message-Id: <20210519183951.3946870-8-jsnow@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py index ffdd4298b6..4959630ce6 100644 --- a/scripts/qapi/parser.py +++ b/scripts/qapi/parser.py @@ -249,6 +249,8 @@ class QAPISchemaParser: raise QAPIParseError(self, "expected string or '}'") while True: key = self.val + assert isinstance(key, str) # Guaranteed by tok == "'" + self.accept() if self.tok != ':': raise QAPIParseError(self, "expected ':'")