Skip to content


qapi: Fix code generation with Python 3.5
Browse files Browse the repository at this point in the history
Recent commit 3e7fb58 "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: 3e7fb58
Signed-off-by: Markus Armbruster <>
Reviewed-by: Philippe Mathieu-Daudé <>
Reviewed-by: Alex Bennée <>
Tested-by: Thomas Huth <>
Tested-by: Philippe Mathieu-Daudé <>
Tested-by: BALATON Zoltan <>
Tested-by: Alex Bennée <>
Signed-off-by: Peter Maydell <>
  • Loading branch information
Markus Armbruster authored and pm215 committed Jan 20, 2020
1 parent 26deea0 commit 43d1455
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/qapi/
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ def __init__(self, fname): =
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
Expand Down

0 comments on commit 43d1455

Please sign in to comment.