[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 6/8] qapi: Revert an accidental change from list to view objec
From: |
Kevin Wolf |
Subject: |
[PATCH v4 6/8] qapi: Revert an accidental change from list to view object |
Date: |
Fri, 17 Sep 2021 18:13:18 +0200 |
From: Markus Armbruster <armbru@redhat.com>
A long time ago, commit 23a4b2c6f1 "qapi: Eliminate
QAPISchemaObjectType.check() variable members" replaced the manual
building of the list of members by seen.values(), where @seen is an
OrderedDict mapping names to members. The list is then stored in
self.members.
With Python 2, this is an innocent change: seen.values() returns "a
copy of the dictionary’s list of values".
With Python 3, it returns a dictionary view object instad. These
"provide a dynamic view on the dictionary’s entries, which means that
when the dictionary changes, the view reflects these changes."
Commit 23a4b2c6f1 predates the first mention of Python 3 in
scripts/qapi/ by years. If we had wanted a view object then, we'd
have used seen.viewvalues().
The accidental change of self.members from list to view object keeps
@seen alive longer. Not wanted, but harmless enough. I believe
that's all.
However, the change is in the next commit's way, which wants to mess
with self.members. Revert it.
All other uses of .values() in scripts/qapi/ are of the form
for ... in dict.values():
where the change to view object is just fine. Same for .keys() and
.items().
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
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 3d72c7dfc9..87f80f8de2 100644
--- a/scripts/qapi/schema.py
+++ b/scripts/qapi/schema.py
@@ -440,7 +440,7 @@ def check(self, schema):
for m in self.local_members:
m.check(schema)
m.check_clash(self.info, seen)
- members = seen.values()
+ members = list(seen.values())
if self.variants:
self.variants.check(schema, seen)
--
2.31.1
- [PATCH v4 0/8] qapi: Add support for aliases, Kevin Wolf, 2021/09/17
- [PATCH v4 1/8] qapi: Add interfaces for alias support to Visitor, Kevin Wolf, 2021/09/17
- [PATCH v4 4/8] qapi: Store Error in StackObject.h for qobject-input-visitor, Kevin Wolf, 2021/09/17
- [PATCH v4 6/8] qapi: Revert an accidental change from list to view object,
Kevin Wolf <=
- [PATCH v4 7/8] qapi: Add support for aliases, Kevin Wolf, 2021/09/17
- [PATCH v4 5/8] qapi: Apply aliases in qobject-input-visitor, Kevin Wolf, 2021/09/17
- [PATCH v4 3/8] qapi: Simplify full_name_nth() in qobject-input-visitor, Kevin Wolf, 2021/09/17
- [PATCH v4 2/8] qapi: Remember alias definitions in qobject-input-visitor, Kevin Wolf, 2021/09/17
- [PATCH v4 8/8] tests/qapi-schema: Test cases for aliases, Kevin Wolf, 2021/09/17