python: Support old buffer protocol when unpack. (experimental)

This commit is contained in:
INADA Naoki 2010-11-03 03:11:00 +09:00
parent 3903979a84
commit a09c85ff9c
3 changed files with 65 additions and 113 deletions

View file

@ -7,10 +7,10 @@ from msgpack import packb, unpackb
def test_unpack_buffer():
from array import array
buf = array('b')
buf.fromstring(packb(['foo', 'bar']))
buf = array('c')
buf.fromstring(packb(('foo', 'bar')))
obj = unpackb(buf)
assert_equal(['foo', 'bar'], obj)
assert_equal(('foo', 'bar'), obj)
if __name__ == '__main__':
main()