mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-27 00:19:53 +03:00
one-shot unpack
This commit is contained in:
parent
1fa750a0d7
commit
c360433de7
|
@ -95,10 +95,9 @@ class MessagePackParser(BaseParser):
|
||||||
`files` will always be `None`.
|
`files` will always be `None`.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
return msgpack.Unpacker(
|
return msgpack.unpackb(stream,
|
||||||
stream,
|
|
||||||
use_list=True,
|
use_list=True,
|
||||||
object_hook=self._decode_object).unpack()
|
object_hook=self._decode_object)
|
||||||
except Exception, exc:
|
except Exception, exc:
|
||||||
raise ParseError('MessagePack parse error - %s' % unicode(exc))
|
raise ParseError('MessagePack parse error - %s' % unicode(exc))
|
||||||
|
|
||||||
|
|
|
@ -351,7 +351,7 @@ if msgpack:
|
||||||
parser = MessagePackParser()
|
parser = MessagePackParser()
|
||||||
|
|
||||||
content = renderer.render(obj, 'application/msgpack')
|
content = renderer.render(obj, 'application/msgpack')
|
||||||
data = parser.parse(StringIO(content))
|
data = parser.parse(content)
|
||||||
self.assertEquals(obj, data)
|
self.assertEquals(obj, data)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user