cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
0a122b
From 73cd8a69f21978e950706a633d9a25e10fe6ad2d Mon Sep 17 00:00:00 2001
0a122b
Message-Id: <73cd8a69f21978e950706a633d9a25e10fe6ad2d.1387369730.git.minovotn@redhat.com>
0a122b
In-Reply-To: <091eecc4fa42754760dfff393dabcc2b444e9693.1387369730.git.minovotn@redhat.com>
0a122b
References: <091eecc4fa42754760dfff393dabcc2b444e9693.1387369730.git.minovotn@redhat.com>
0a122b
From: Markus Armbruster <armbru@redhat.com>
0a122b
Date: Tue, 10 Dec 2013 15:29:17 +0100
0a122b
Subject: [PATCH 17/21] qapi.py: Fix diagnosing non-objects at a schema's
0a122b
 top-level
0a122b
0a122b
RH-Author: Markus Armbruster <armbru@redhat.com>
0a122b
Message-id: <1386689361-30281-15-git-send-email-armbru@redhat.com>
0a122b
Patchwork-id: 56129
0a122b
O-Subject: [PATCH 7.0 qemu-kvm 14/18] qapi.py: Fix diagnosing non-objects at a schema's top-level
0a122b
Bugzilla: 997915
0a122b
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
0a122b
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
0a122b
RH-Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
0a122b
0a122b
From: Markus Armbruster <armbru@redhat.com>
0a122b
0a122b
Report syntax error instead of crashing.
0a122b
0a122b
Signed-off-by: Markus Armbruster <armbru@redhat.com>
0a122b
Reviewed-by: Eric Blake <eblake@redhat.com>
0a122b
Message-id: 1374939721-7876-8-git-send-email-armbru@redhat.com
0a122b
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
0a122b
(cherry picked from commit 5f3cd2b717c949f3afb502fb4c81193eb18ce6aa)
0a122b
---
0a122b
 scripts/qapi.py                               | 10 ++++++----
0a122b
 tests/qapi-schema/non-objects.err             |  2 +-
0a122b
 tests/qapi-schema/quoted-structural-chars.err |  2 +-
0a122b
 3 files changed, 8 insertions(+), 6 deletions(-)
0a122b
0a122b
Signed-off-by: Michal Novotny <minovotn@redhat.com>
0a122b
---
0a122b
 scripts/qapi.py                               | 10 ++++++----
0a122b
 tests/qapi-schema/non-objects.err             |  2 +-
0a122b
 tests/qapi-schema/quoted-structural-chars.err |  2 +-
0a122b
 3 files changed, 8 insertions(+), 6 deletions(-)
0a122b
0a122b
diff --git a/scripts/qapi.py b/scripts/qapi.py
0a122b
index 12fb29a..75fc282 100644
0a122b
--- a/scripts/qapi.py
0a122b
+++ b/scripts/qapi.py
0a122b
@@ -64,7 +64,7 @@ class QAPISchema:
0a122b
         self.accept()
0a122b
 
0a122b
         while self.tok != None:
0a122b
-            self.exprs.append(self.get_expr())
0a122b
+            self.exprs.append(self.get_expr(False))
0a122b
 
0a122b
     def accept(self):
0a122b
         while True:
0a122b
@@ -117,7 +117,7 @@ class QAPISchema:
0a122b
             if self.tok != ':':
0a122b
                 raise QAPISchemaError(self, 'Expected ":"')
0a122b
             self.accept()
0a122b
-            expr[key] = self.get_expr()
0a122b
+            expr[key] = self.get_expr(True)
0a122b
             if self.tok == '}':
0a122b
                 self.accept()
0a122b
                 return expr
0a122b
@@ -135,7 +135,7 @@ class QAPISchema:
0a122b
         if not self.tok in [ '{', '[', "'" ]:
0a122b
             raise QAPISchemaError(self, 'Expected "{", "[", "]" or string')
0a122b
         while True:
0a122b
-            expr.append(self.get_expr())
0a122b
+            expr.append(self.get_expr(True))
0a122b
             if self.tok == ']':
0a122b
                 self.accept()
0a122b
                 return expr
0a122b
@@ -143,7 +143,9 @@ class QAPISchema:
0a122b
                 raise QAPISchemaError(self, 'Expected "," or "]"')
0a122b
             self.accept()
0a122b
 
0a122b
-    def get_expr(self):
0a122b
+    def get_expr(self, nested):
0a122b
+        if self.tok != '{' and not nested:
0a122b
+            raise QAPISchemaError(self, 'Expected "{"')
0a122b
         if self.tok == '{':
0a122b
             self.accept()
0a122b
             expr = self.get_members()
0a122b
diff --git a/tests/qapi-schema/non-objects.err b/tests/qapi-schema/non-objects.err
0a122b
index 48c849d..a6c2dc2 100644
0a122b
--- a/tests/qapi-schema/non-objects.err
0a122b
+++ b/tests/qapi-schema/non-objects.err
0a122b
@@ -1 +1 @@
0a122b
-Crashed: <type 'exceptions.AttributeError'>
0a122b
+<stdin>:1:1: Expected "{"
0a122b
diff --git a/tests/qapi-schema/quoted-structural-chars.err b/tests/qapi-schema/quoted-structural-chars.err
0a122b
index 48c849d..a6c2dc2 100644
0a122b
--- a/tests/qapi-schema/quoted-structural-chars.err
0a122b
+++ b/tests/qapi-schema/quoted-structural-chars.err
0a122b
@@ -1 +1 @@
0a122b
-Crashed: <type 'exceptions.AttributeError'>
0a122b
+<stdin>:1:1: Expected "{"
0a122b
-- 
0a122b
1.7.11.7
0a122b