diff mbox series

[09/26] qapi/parser.py: assert get_expr returns object in outer loop

Message ID 20200922223525.4085762-10-jsnow@redhat.com
State New
Headers show
Series qapi: static typing conversion, pt5 | expand

Commit Message

John Snow Sept. 22, 2020, 10:35 p.m. UTC
get_expr can return many things, depending on where it is used. In the
outer parsing loop, we expect and require it to return an object.

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

Patch

diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py
index 6774b6c736..1bc33e85ea 100644
--- a/scripts/qapi/parser.py
+++ b/scripts/qapi/parser.py
@@ -94,6 +94,9 @@  def _parse(self):
                 continue
 
             expr = self.get_expr(False)
+            if not isinstance(expr, dict):
+                raise QAPISemError(info, "Expecting object statement")
+
             if 'include' in expr:
                 self.reject_expr_doc(cur_doc)
                 if len(expr) != 1: