diff options
author | Raymond Hettinger <python@rcn.com> | 2007-04-05 18:00:03 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2007-04-05 18:00:03 (GMT) |
commit | 7a3d41f4ca7a94267063ee50250ed5199ba8daf5 (patch) | |
tree | d20bb061ef6e96a2d3a08297ba354d4341aa33ab /Lib/test/test_struct.py | |
parent | 18ffe42b4b88699b8e030c5d8b0e79593b18dab1 (diff) | |
download | cpython-7a3d41f4ca7a94267063ee50250ed5199ba8daf5.zip cpython-7a3d41f4ca7a94267063ee50250ed5199ba8daf5.tar.gz cpython-7a3d41f4ca7a94267063ee50250ed5199ba8daf5.tar.bz2 |
Bug #1563759: struct.unpack doens't support buffer protocol objects
Diffstat (limited to 'Lib/test/test_struct.py')
-rw-r--r-- | Lib/test/test_struct.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py index f5019bf..ea3a518 100644 --- a/Lib/test/test_struct.py +++ b/Lib/test/test_struct.py @@ -614,11 +614,19 @@ 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 + data1 = array.array('B', '\x12\x34\x56\x78') + data2 = buffer('......\x12\x34\x56\x78......', 6, 4) + for data in [data1, data2]: + 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() def test_bool(): for prefix in tuple("<>!=")+('',): |