qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, jsnow@redhat.com, armbru@redhat.com
Subject: [PATCH v4 6/8] qapi: Revert an accidental change from list to view object
Date: Fri, 17 Sep 2021 18:13:18 +0200	[thread overview]
Message-ID: <20210917161320.201086-7-kwolf@redhat.com> (raw)
In-Reply-To: <20210917161320.201086-1-kwolf@redhat.com>

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



  parent reply	other threads:[~2021-09-17 16:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-17 16:13 [PATCH v4 0/8] qapi: Add support for aliases Kevin Wolf
2021-09-17 16:13 ` [PATCH v4 1/8] qapi: Add interfaces for alias support to Visitor Kevin Wolf
2021-09-17 16:13 ` [PATCH v4 2/8] qapi: Remember alias definitions in qobject-input-visitor Kevin Wolf
2021-09-17 16:13 ` [PATCH v4 3/8] qapi: Simplify full_name_nth() " Kevin Wolf
2021-09-17 16:13 ` [PATCH v4 4/8] qapi: Store Error in StackObject.h for qobject-input-visitor Kevin Wolf
2021-09-17 16:13 ` [PATCH v4 5/8] qapi: Apply aliases in qobject-input-visitor Kevin Wolf
2021-09-17 16:13 ` Kevin Wolf [this message]
2021-09-17 16:13 ` [PATCH v4 7/8] qapi: Add support for aliases Kevin Wolf
2021-09-17 16:13 ` [PATCH v4 8/8] tests/qapi-schema: Test cases " Kevin Wolf
2021-10-01  9:28 ` [PATCH v4 0/8] qapi: Add support " Kevin Wolf
2021-10-26 21:23 ` John Snow
2021-10-27 10:31   ` Kevin Wolf
2021-10-27 15:34     ` John Snow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210917161320.201086-7-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=armbru@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).