Skip to content

Commit

Permalink
Merge pull request #47568 from terminalmage/salt-jenkins-971
Browse files Browse the repository at this point in the history
salt.serializers.yaml/yamlex: remove invalid multi_constructor
  • Loading branch information
Nicole Thomas committed May 10, 2018
2 parents e3ee705 + ecf5dc8 commit 2fcb108
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 7 additions & 1 deletion salt/serializers/yaml.py
Expand Up @@ -11,6 +11,7 @@

from __future__ import absolute_import, print_function, unicode_literals
import datetime
import logging

import yaml
from yaml.constructor import ConstructorError
Expand All @@ -22,6 +23,8 @@

__all__ = ['deserialize', 'serialize', 'available']

log = logging.getLogger(__name__)

available = True

# prefer C bindings over python when available
Expand All @@ -46,14 +49,17 @@ def deserialize(stream_or_string, **options):
try:
return yaml.load(stream_or_string, **options)
except ScannerError as error:
log.exception('Error encountered while deserializing')
err_type = ERROR_MAP.get(error.problem, 'Unknown yaml render error')
line_num = error.problem_mark.line + 1
raise DeserializationError(err_type,
line_num,
error.problem_mark.buffer)
except ConstructorError as error:
log.exception('Error encountered while deserializing')
raise DeserializationError(error)
except Exception as error:
log.exception('Error encountered while deserializing')
raise DeserializationError(error)


Expand All @@ -74,6 +80,7 @@ def serialize(obj, **options):
return response[:-1]
return response
except Exception as error:
log.exception('Error encountered while serializing')
raise SerializationError(error)


Expand Down Expand Up @@ -108,7 +115,6 @@ class Loader(BaseLoader): # pylint: disable=W0232
Loader.add_multi_constructor('tag:yaml.org,2002:str', Loader.construct_yaml_str)
Loader.add_multi_constructor('tag:yaml.org,2002:seq', Loader.construct_yaml_seq)
Loader.add_multi_constructor('tag:yaml.org,2002:map', Loader.construct_yaml_map)
Loader.add_multi_constructor(None, Loader.construct_undefined)


class Dumper(BaseDumper): # pylint: disable=W0232
Expand Down
5 changes: 4 additions & 1 deletion salt/serializers/yamlex.py
Expand Up @@ -150,14 +150,17 @@ def deserialize(stream_or_string, **options):
try:
return yaml.load(stream_or_string, **options)
except ScannerError as error:
log.exception('Error encountered while deserializing')
err_type = ERROR_MAP.get(error.problem, 'Unknown yaml render error')
line_num = error.problem_mark.line + 1
raise DeserializationError(err_type,
line_num,
error.problem_mark.buffer)
except ConstructorError as error:
log.exception('Error encountered while deserializing')
raise DeserializationError(error)
except Exception as error:
log.exception('Error encountered while deserializing')
raise DeserializationError(error)


Expand All @@ -178,6 +181,7 @@ def serialize(obj, **options):
return response[:-1]
return response
except Exception as error:
log.exception('Error encountered while serializing')
raise SerializationError(error)


Expand Down Expand Up @@ -322,7 +326,6 @@ def resolve_sls_tag(self, node):
Loader.add_multi_constructor('tag:yaml.org,2002:set', Loader.construct_yaml_set)
Loader.add_multi_constructor('tag:yaml.org,2002:seq', Loader.construct_yaml_seq)
Loader.add_multi_constructor('tag:yaml.org,2002:map', Loader.construct_yaml_map)
Loader.add_multi_constructor(None, Loader.construct_undefined)


class SLSMap(OrderedDict):
Expand Down

0 comments on commit 2fcb108

Please sign in to comment.