From 7c610ce6a9950a49148fc3d37ed353958ca8d776 Mon Sep 17 00:00:00 2001 From: John Snow Date: Wed, 19 May 2021 14:39:41 -0400 Subject: [PATCH] qapi/parser: Assert lexer value is a string The type checker can't narrow the type of the token value to string, because it's only loosely correlated with the return token. We know that a token of '#' should always have a "str" value. Add an assertion. Signed-off-by: John Snow Message-Id: <20210519183951.3946870-6-jsnow@redhat.com> Reviewed-by: Markus Armbruster Signed-off-by: Markus Armbruster --- scripts/qapi/parser.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py index d620706fff..0bc852eda7 100644 --- a/scripts/qapi/parser.py +++ b/scripts/qapi/parser.py @@ -304,6 +304,7 @@ class QAPISchemaParser: cur_doc = QAPIDoc(self, info) self.accept(False) while self.tok == '#': + assert isinstance(self.val, str) if self.val.startswith('##'): # End of doc comment if self.val != '##':