Commit 3d999e4b by Tom Christie

Merge pull request #1211 from robhudson/fix-six

Fixed exception handling with YAML and XML parsers.
parents 7ef83cf0 e33435d0
...@@ -83,7 +83,7 @@ class YAMLParser(BaseParser): ...@@ -83,7 +83,7 @@ class YAMLParser(BaseParser):
data = stream.read().decode(encoding) data = stream.read().decode(encoding)
return yaml.safe_load(data) return yaml.safe_load(data)
except (ValueError, yaml.parser.ParserError) as exc: except (ValueError, yaml.parser.ParserError) as exc:
raise ParseError('YAML parse error - %s' % six.u(exc)) raise ParseError('YAML parse error - %s' % six.text_type(exc))
class FormParser(BaseParser): class FormParser(BaseParser):
...@@ -153,7 +153,7 @@ class XMLParser(BaseParser): ...@@ -153,7 +153,7 @@ class XMLParser(BaseParser):
try: try:
tree = etree.parse(stream, parser=parser, forbid_dtd=True) tree = etree.parse(stream, parser=parser, forbid_dtd=True)
except (etree.ParseError, ValueError) as exc: except (etree.ParseError, ValueError) as exc:
raise ParseError('XML parse error - %s' % six.u(exc)) raise ParseError('XML parse error - %s' % six.text_type(exc))
data = self._xml_convert(tree.getroot()) data = self._xml_convert(tree.getroot())
return data return data
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment