[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 05/15] qapi/parser: Assert lexer value is a string
From: |
Markus Armbruster |
Subject: |
[PULL 05/15] qapi/parser: Assert lexer value is a string |
Date: |
Thu, 20 May 2021 19:52:46 +0200 |
From: John Snow <jsnow@redhat.com>
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 <jsnow@redhat.com>
Message-Id: <20210519183951.3946870-6-jsnow@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@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 d620706fff..0bc852eda7 100644
--- a/scripts/qapi/parser.py
+++ b/scripts/qapi/parser.py
@@ -304,6 +304,7 @@ def get_doc(self, info):
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 != '##':
--
2.26.3
- [PULL 09/15] qapi: add must_match helper, (continued)
- [PULL 09/15] qapi: add must_match helper, Markus Armbruster, 2021/05/20
- [PULL 10/15] qapi/parser: Fix token membership tests when token can be None, Markus Armbruster, 2021/05/20
- [PULL 06/15] qapi/parser: enforce all top-level expressions must be dict in _parse(), Markus Armbruster, 2021/05/20
- [PULL 11/15] qapi/parser: Rework _check_pragma_list_of_str as a TypeGuard, Markus Armbruster, 2021/05/20
- [PULL 01/15] qapi/parser: Don't try to handle file errors, Markus Armbruster, 2021/05/20
- [PULL 04/15] qapi/parser: factor parsing routine into method, Markus Armbruster, 2021/05/20
- [PULL 15/15] qapi/parser: add docstrings, Markus Armbruster, 2021/05/20
- [PULL 13/15] qapi/parser: Remove superfluous list comprehension, Markus Armbruster, 2021/05/20
- [PULL 07/15] qapi/parser: assert object keys are strings, Markus Armbruster, 2021/05/20
- [PULL 02/15] qapi: Add test for nonexistent schema file, Markus Armbruster, 2021/05/20
- [PULL 05/15] qapi/parser: Assert lexer value is a string,
Markus Armbruster <=
- [PULL 03/15] qapi/source: Remove line number from QAPISourceInfo initializer, Markus Armbruster, 2021/05/20
- [PULL 08/15] qapi/parser: Use @staticmethod where appropriate, Markus Armbruster, 2021/05/20
- [PULL 12/15] qapi/parser: add type hint annotations, Markus Armbruster, 2021/05/20
- [PULL 14/15] qapi/parser: allow 'ch' variable name, Markus Armbruster, 2021/05/20
- Re: [PULL 00/15] QAPI patches patches for 2021-05-20, Peter Maydell, 2021/05/21