[Top][All Lists]

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

Re: [PATCH] qapi: Fix code generation with Python 3.5

From: Philippe Mathieu-Daudé
Subject: Re: [PATCH] qapi: Fix code generation with Python 3.5
Date: Sat, 18 Jan 2020 09:33:11 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2

On 1/17/20 11:49 AM, Markus Armbruster wrote:
Thomas Huth <address@hidden> writes:

On 16/01/2020 21.25, Markus Armbruster wrote:
Recent commit 3e7fb5811b "qapi: Fix code generation for empty modules"
modules" switched QAPISchema.visit() from

     for entity in self._entity_list:

effectively to

     for mod in self._module_dict.values():
         for entity in mod._entity_list:

Visits in the same order as long as .values() is in insertion order.
That's the case only for Python 3.6 and later.  Before, it's in some
arbitrary order, which results in broken generated code.

Fix by making self._module_dict an OrderedDict rather than a dict.

Fixes: 3e7fb5811baab213dcc7149c3aa69442d683c26c
Signed-off-by: Markus Armbruster <address@hidden>
  scripts/qapi/schema.py | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
index 0bfc5256fb..5100110fa2 100644
--- a/scripts/qapi/schema.py
+++ b/scripts/qapi/schema.py
@@ -795,7 +795,7 @@ class QAPISchema(object):
          self.docs = parser.docs
          self._entity_list = []
          self._entity_dict = {}
-        self._module_dict = {}
+        self._module_dict = OrderedDict()
          self._schema_dir = os.path.dirname(fname)
          self._make_module(None) # built-ins

Thanks, this fixes the problems on Travis for me!

Tested-by: Thomas Huth <address@hidden>

Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Tested-by: Philippe Mathieu-Daudé <address@hidden>

Peter, could you maybe apply this directly to the master branch as a
build fix?

The commit message isn't quite right: s/Visits in the same order/Visits
modules in the same order/.  Peter, want me to respin for that?

Since it is a single patch, it shouldn't be too much work to respin :)

I agree this patch is candidate for direct fix on /master.



reply via email to

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