From 1f389a9bee22f00bddec865d5044a10c7d465c03 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Mon, 11 Feb 2013 11:06:32 +0000 Subject: yaml: use Safe Loaders and Dumpers This is equivalent to using yaml.safe_load(), but lets us customise how yaml is parsed. --- morphlib/yamlparse.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'morphlib/yamlparse.py') diff --git a/morphlib/yamlparse.py b/morphlib/yamlparse.py index 7e591b08..99599618 100644 --- a/morphlib/yamlparse.py +++ b/morphlib/yamlparse.py @@ -23,7 +23,7 @@ if morphlib.got_yaml: # pragma: no cover if morphlib.got_yaml: # pragma: no cover - class OrderedDictYAMLLoader(yaml.Loader): + class OrderedDictYAMLLoader(yaml.SafeLoader): """A YAML loader that loads mappings into ordered dictionaries. When YAML is loaded with this Loader, it loads mappings as ordered @@ -35,7 +35,7 @@ if morphlib.got_yaml: # pragma: no cover """ def __init__(self, *args, **kwargs): - yaml.Loader.__init__(self, *args, **kwargs) + yaml.SafeLoader.__init__(self, *args, **kwargs) # When YAML encounters a mapping (which YAML identifies with # the given tag), it will use construct_yaml_map to read it as @@ -72,7 +72,7 @@ if morphlib.got_yaml: # pragma: no cover mapping[key] = value return mapping - class OrderedDictYAMLDumper(yaml.Dumper): + class OrderedDictYAMLDumper(yaml.SafeDumper): """A YAML dumper that will dump OrderedDicts as mappings. When YAML is dumped with this Dumper, it dumps OrderedDicts as @@ -85,7 +85,7 @@ if morphlib.got_yaml: # pragma: no cover """ def __init__(self, *args, **kwargs): - yaml.Dumper.__init__(self, *args, **kwargs) + yaml.SafeDumper.__init__(self, *args, **kwargs) # When YAML sees an OrderedDict, use represent_ordered_dict to # dump it -- cgit v1.2.1