qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 10/26] qapi/parser.py: assert object keys are strings


From: John Snow
Subject: [PATCH 10/26] qapi/parser.py: assert object keys are strings
Date: Tue, 22 Sep 2020 18:35:09 -0400

Since values can also be other data types, add an assertion to ensure
we're dealing with strings.

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

diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py
index 1bc33e85ea..756c904257 100644
--- a/scripts/qapi/parser.py
+++ b/scripts/qapi/parser.py
@@ -256,6 +256,8 @@ def get_members(self):
             raise self._parse_error("expected string or '}'")
         while True:
             key = self.val
+            assert isinstance(key, str), f"expected str, got {type(key)!s}"
+
             self.accept()
             if self.tok != ':':
                 raise self._parse_error("expected ':'")
-- 
2.26.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]