mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Properly raise ConstructorError in construct_mapping
We were passing the wrong arguments to this exception's constructor. This commit changes the exceptions so that they end up with the proper attributes, allowing them to be successfully interpreted when caught.
This commit is contained in:
parent
b4e24a69e6
commit
3688ae0440
@ -76,18 +76,25 @@ class SaltYamlSafeLoader(yaml.SafeLoader, object):
|
|||||||
|
|
||||||
self.flatten_mapping(node)
|
self.flatten_mapping(node)
|
||||||
|
|
||||||
|
context = 'while constructing a mapping'
|
||||||
mapping = self.dictclass()
|
mapping = self.dictclass()
|
||||||
for key_node, value_node in node.value:
|
for key_node, value_node in node.value:
|
||||||
key = self.construct_object(key_node, deep=deep)
|
key = self.construct_object(key_node, deep=deep)
|
||||||
try:
|
try:
|
||||||
hash(key)
|
hash(key)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
err = ('While constructing a mapping {0} found unacceptable '
|
raise ConstructorError(
|
||||||
'key {1}').format(node.start_mark, key_node.start_mark)
|
context,
|
||||||
raise ConstructorError(err)
|
node.start_mark,
|
||||||
|
"found unacceptable key {0}".format(key_node.value),
|
||||||
|
key_node.start_mark)
|
||||||
value = self.construct_object(value_node, deep=deep)
|
value = self.construct_object(value_node, deep=deep)
|
||||||
if key in mapping:
|
if key in mapping:
|
||||||
raise ConstructorError('Conflicting ID \'{0}\''.format(key))
|
raise ConstructorError(
|
||||||
|
context,
|
||||||
|
node.start_mark,
|
||||||
|
"found conflicting ID '{0}'".format(key),
|
||||||
|
key_node.start_mark)
|
||||||
mapping[key] = value
|
mapping[key] = value
|
||||||
return mapping
|
return mapping
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user