osbuild-mpp: ConstructorError was undefined

ConstructorError is part of the yaml.constructor module.
This commit is contained in:
Jelle van der Waa 2021-12-02 08:02:49 +01:00 committed by Christian Kellner
parent 03af8c632a
commit 76c1b5cf25

View file

@ -281,15 +281,15 @@ from osbuild.util.rhsm import Subscriptions
class YamlOrderedLoader(yaml.Loader):
def construct_mapping(self, node, deep=False):
if not isinstance(node, yaml.MappingNode):
raise ConstructorError(None, None,
"expected a mapping node, but found %s" % node.id,
node.start_mark)
raise yaml.constructor.ConstructorError(None, None,
"expected a mapping node, but found %s" % node.id,
node.start_mark)
mapping = collections.OrderedDict()
for key_node, value_node in node.value:
key = self.construct_object(key_node, deep=deep)
if not isinstance(key, collections.abc.Hashable):
raise ConstructorError("while constructing a mapping", node.start_mark,
"found unhashable key", key_node.start_mark)
raise yaml.constructor.ConstructorError("while constructing a mapping", node.start_mark,
"found unhashable key", key_node.start_mark)
value = self.construct_object(value_node, deep=deep)
mapping[key] = value
return mapping