Commit 0002b557 authored by Markus Armbruster's avatar Markus Armbruster
Browse files

qapi: Eliminate accidental global frontend state



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: default avatarMarkus Armbruster <armbru@redhat.com>
Reviewed-by: default avatarEric Blake <eblake@redhat.com>
Message-Id: <20191018074345.24034-4-armbru@redhat.com>
parent 2a7bbedd
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -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: