Fixed exception handling with YAML and XML parsers.

This commit is contained in:
Rob Hudson 2013-10-31 15:03:50 -07:00
parent 7ef83cf020
commit e33435d0da

View File

@ -83,7 +83,7 @@ class YAMLParser(BaseParser):
data = stream.read().decode(encoding)
return yaml.safe_load(data)
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):
@ -153,7 +153,7 @@ class XMLParser(BaseParser):
try:
tree = etree.parse(stream, parser=parser, forbid_dtd=True)
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())
return data