Bug #1563759: struct.unpack doens't support buffer protocol objects

This commit is contained in:
Raymond Hettinger 2007-04-04 20:32:03 +00:00
parent 8863544522
commit 3608f0570e
3 changed files with 25 additions and 3 deletions

View file

@ -612,8 +612,14 @@ def test_pack_into_fn():
assertRaises(struct.error, pack_into, small_buf, 0, test_string)
assertRaises(struct.error, pack_into, small_buf, 2, test_string)
def test_unpack_with_buffer():
# SF bug 1563759: struct.unpack doens't support buffer protocol objects
data = array.array('B', '\x12\x34\x56\x78')
value, = struct.unpack('>I', data)
vereq(value, 0x12345678)
# Test methods to pack and unpack from buffers rather than strings.
test_unpack_from()
test_pack_into()
test_pack_into_fn()
test_unpack_with_buffer()