From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Subject: [PULL 03/12] qapi: Eliminate accidental global frontend state
Date: Tue, 22 Oct 2019 09:56:06 +0200 [thread overview]
Message-ID: <20191022075615.956-4-armbru@redhat.com> (raw)
In-Reply-To: <20191022075615.956-1-armbru@redhat.com>
The frontend can't be run more than once due to its global state.
A future commit will want to do that.
The only global frontend state remaining is accidental:
QAPISchemaParser.__init__()'s parameter previously_included=[].
Python evaluates the default once, at definition time. Any
modifications to it are visible in subsequent calls. Well-known
Python trap. Change the default to None and replace it by the real
default in the function body. Use the opportunity to convert
previously_included to a set.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20191018074345.24034-4-armbru@redhat.com>
---
scripts/qapi/common.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
index 5abab44302..9d5c05f6a1 100644
--- a/scripts/qapi/common.py
+++ b/scripts/qapi/common.py
@@ -391,8 +391,9 @@ class QAPIDoc(object):
class QAPISchemaParser(object):
- def __init__(self, fname, previously_included=[], incl_info=None):
- previously_included.append(os.path.abspath(fname))
+ def __init__(self, fname, previously_included=None, incl_info=None):
+ previously_included = previously_included or set()
+ previously_included.add(os.path.abspath(fname))
try:
if sys.version_info[0] >= 3:
--
2.21.0
next prev parent reply other threads:[~2019-10-22 7:57 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-22 7:56 [PULL 00/12] QAPI patches for 2019-10-22 Markus Armbruster
2019-10-22 7:56 ` [PULL 01/12] qapi: Don't suppress doc generation without pragma doc-required Markus Armbruster
2019-10-22 7:56 ` [PULL 02/12] qapi: Store pragma state in QAPISourceInfo, not global state Markus Armbruster
2019-10-22 7:56 ` Markus Armbruster [this message]
2019-10-22 7:56 ` [PULL 04/12] qapi: Speed up frontend tests Markus Armbruster
2019-10-22 7:56 ` [PULL 05/12] qapi: Move gen_enum(), gen_enum_lookup() back to qapi/types.py Markus Armbruster
2019-10-22 7:56 ` [PULL 06/12] qapi: Split up scripts/qapi/common.py Markus Armbruster
2019-10-22 7:56 ` [PULL 07/12] qapi: Clear scripts/qapi/doc.py executable bits again Markus Armbruster
2019-10-22 7:56 ` [PULL 08/12] tests/qapi-schema: Tidy up test output indentation Markus Armbruster
2019-10-22 7:56 ` [PULL 09/12] qapi: Add feature flags to commands Markus Armbruster
2019-10-22 7:56 ` [PULL 10/12] tests: qapi: Test 'features' of commands Markus Armbruster
2019-10-22 7:56 ` [PULL 11/12] tests/qapi-schema: Cover feature documentation comments Markus Armbruster
2019-10-22 7:56 ` [PULL 12/12] qapi: Allow introspecting fix for savevm's cooperation with blockdev Markus Armbruster
2019-10-22 9:32 ` [PULL 00/12] QAPI patches for 2019-10-22 Peter Maydell
2019-10-22 10:49 ` 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=20191022075615.956-4-armbru@redhat.com \
--to=armbru@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.