mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-10 19:56:59 +03:00
Fixed exception handling with YAML and XML parsers.
This commit is contained in:
parent
7ef83cf020
commit
e33435d0da
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user