[PATCH 08/26] qapi/parser.py: Assert lexer value is a string

John Snow posted 26 patches 5 years, 1 month ago
[PATCH 08/26] qapi/parser.py: Assert lexer value is a string
Posted by John Snow 5 years, 1 month ago
The type checker can't constrain the token value to string in this case,
because it's only loosely correlated with the return token, which is
"stringly typed".

Signed-off-by: John Snow <jsnow@redhat.com>
---
 scripts/qapi/parser.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py
index 78355ca93f..6774b6c736 100644
--- a/scripts/qapi/parser.py
+++ b/scripts/qapi/parser.py
@@ -312,6 +312,7 @@ def _get_doc(self, info):
         cur_doc = QAPIDoc(info)
         self.accept(False)
         while self.tok == '#':
+            assert isinstance(self.val, str), "Expected str value"
             if self.val.startswith('##'):
                 # End of doc comment
                 if self.val != '##':
-- 
2.26.2