meta: fix lookup of invalid schemata

We need to initialize `schema` to `None`, otherwise it will be an access
to an uninitialized variable when looking up invalid schemata:

    [...]
      File "[...]/osbuild/meta.py", line 583, in get_schema
        schema = Schema(schema, name or klass)
    UnboundLocalError: local variable 'schema' referenced before assignment

Signed-off-by: David Rheinsberg <david.rheinsberg@gmail.com>
This commit is contained in:
David Rheinsberg 2022-07-25 12:03:37 +02:00 committed by Christian Kellner
parent 4a40b732ea
commit 38662b22a6

View file

@ -564,6 +564,7 @@ class Index:
`None` and any validation will fail.
"""
cached_schema: Optional[Schema] = self._schemata.get((klass, name, version))
schema = None
if cached_schema is not None:
return cached_schema