From: Markus Armbruster <armbru@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: jsnow@redhat.com, qemu-devel@nongnu.org
Subject: Re: [PATCH v3 5/6] qapi: Add support for aliases
Date: Tue, 14 Sep 2021 13:00:33 +0200 [thread overview]
Message-ID: <874kanbewe.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <87k0jjeeg0.fsf@dusky.pond.sub.org> (Markus Armbruster's message of "Tue, 14 Sep 2021 10:42:07 +0200")
Markus Armbruster <armbru@redhat.com> writes:
> Kevin Wolf <kwolf@redhat.com> writes:
>
>> Am 06.09.2021 um 17:24 hat Markus Armbruster geschrieben:
>>> Kevin Wolf <kwolf@redhat.com> writes:
>>>
>>> > Introduce alias definitions for object types (structs and unions). This
>>> > allows using the same QAPI type and visitor for many syntax variations
>>> > that exist in the external representation, like between QMP and the
>>> > command line. It also provides a new tool for evolving the schema while
>>> > maintaining backwards compatibility during a deprecation period.
>>> >
>>> > Signed-off-by: Kevin Wolf <kwolf@redhat.com>
[...]
>> It don't remember the details of why I needed the list(), but
>> a.check_clash() is (a wrapper around) QAPISchemaMember.check_clash(), so
>> yes, it does change @seen. Specifically, it adds alias names to it.
>
> That's why you need it: seen.values() is a dictionary view object, but
> you need something writable.
>
> The silent change from list to view we got with Python 3 is kind of
> iffy: we store the view in self.members (visible right below), which
> keeps @seen alive.
>
> Would you mind reverting this silent change in a separate one-liner
> patch?
Appending one for your convenience.
[...]
From 4eee60a6a02e425d25167761c47e858e240fe3f8 Mon Sep 17 00:00:00 2001
From: Markus Armbruster <armbru@redhat.com>
Date: Tue, 14 Sep 2021 12:25:09 +0200
Subject: [PATCH] qapi: Revert an accidental change from list to view object
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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>
---
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 d1d27ff7ee..f313dbea27 100644
--- a/scripts/qapi/schema.py
+++ b/scripts/qapi/schema.py
@@ -413,7 +413,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
next prev parent reply other threads:[~2021-09-14 11:03 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-12 16:11 [PATCH v3 0/6] qapi: Add support for aliases Kevin Wolf
2021-08-12 16:11 ` [PATCH v3 1/6] qapi: Add interfaces for alias support to Visitor Kevin Wolf
2021-08-12 16:11 ` [PATCH v3 2/6] qapi: Remember alias definitions in qobject-input-visitor Kevin Wolf
2021-08-12 16:11 ` [PATCH v3 3/6] qapi: Simplify full_name_nth() " Kevin Wolf
2021-08-12 16:11 ` [PATCH v3 4/6] qapi: Apply aliases " Kevin Wolf
2021-09-06 15:16 ` Markus Armbruster
2021-09-08 13:01 ` Kevin Wolf
2021-09-14 6:58 ` Markus Armbruster
2021-09-14 9:35 ` Kevin Wolf
2021-09-14 14:24 ` Markus Armbruster
2021-08-12 16:11 ` [PATCH v3 5/6] qapi: Add support for aliases Kevin Wolf
2021-09-06 15:24 ` Markus Armbruster
2021-09-09 16:39 ` Kevin Wolf
2021-09-14 8:42 ` Markus Armbruster
2021-09-14 11:00 ` Markus Armbruster [this message]
2021-09-14 14:24 ` Kevin Wolf
2021-09-16 7:49 ` Markus Armbruster
2021-08-12 16:11 ` [PATCH v3 6/6] tests/qapi-schema: Test cases " Kevin Wolf
2021-09-06 15:28 ` Markus Armbruster
2021-09-10 15:04 ` Kevin Wolf
2021-09-14 8:59 ` Markus Armbruster
2021-09-14 10:05 ` Kevin Wolf
2021-09-14 13:29 ` Markus Armbruster
2021-09-15 9:24 ` Kevin Wolf
2021-09-17 8:26 ` Markus Armbruster
2021-09-17 15:03 ` Kevin Wolf
2021-10-02 13:33 ` Markus Armbruster
2021-10-04 14:07 ` Kevin Wolf
2021-10-05 13:49 ` Markus Armbruster
2021-10-05 17:05 ` Kevin Wolf
2021-10-06 13:11 ` Markus Armbruster
2021-10-06 16:36 ` Kevin Wolf
2021-10-07 11:06 ` Markus Armbruster
2021-10-07 16:12 ` Kevin Wolf
2021-10-08 10:17 ` Markus Armbruster
2021-10-12 14:00 ` Kevin Wolf
2021-10-11 7:44 ` Markus Armbruster
2021-10-12 14:36 ` Kevin Wolf
2021-10-13 9:41 ` Markus Armbruster
2021-10-13 11:10 ` Markus Armbruster
2021-10-14 9:35 ` Kevin Wolf
2021-08-24 9:36 ` [PATCH v3 0/6] qapi: Add support " Markus Armbruster
2021-09-06 15:32 ` Markus Armbruster
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=874kanbewe.fsf@dusky.pond.sub.org \
--to=armbru@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.