mirror of
https://github.com/python/cpython.git
synced 2025-08-21 17:25:34 +00:00
Bug #1563759: struct.unpack doens't support buffer protocol objects
This commit is contained in:
parent
8863544522
commit
3608f0570e
3 changed files with 25 additions and 3 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue