mirror of
https://github.com/python/cpython.git
synced 2025-09-25 09:50:37 +00:00
Issue #10212: Support new buffer interface for struct.unpack and
cStringIO
This commit is contained in:
parent
1d108bc714
commit
9795ca44fb
5 changed files with 63 additions and 35 deletions
|
@ -496,6 +496,17 @@ class StructTest(unittest.TestCase):
|
|||
|
||||
self.test_unpack_from(cls=buffer)
|
||||
|
||||
def test_unpack_with_memoryview(self):
|
||||
with check_py3k_warnings(("buffer.. not supported in 3.x",
|
||||
DeprecationWarning)):
|
||||
# SF bug 1563759: struct.unpack doesn't support buffer protocol objects
|
||||
data1 = memoryview('\x12\x34\x56\x78')
|
||||
for data in [data1,]:
|
||||
value, = struct.unpack('>I', data)
|
||||
self.assertEqual(value, 0x12345678)
|
||||
|
||||
self.test_unpack_from(cls=memoryview)
|
||||
|
||||
def test_bool(self):
|
||||
class ExplodingBool(object):
|
||||
def __nonzero__(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue