Message224386
I expect struct.pack_into to work for a memoryview. Currently struct.pack_into throws an exception.
>>> import struct
>>> buf = bytearray(10)
>>> struct.pack_into("<B", buf, 0, 99)
>>> buf[0]
99
>>> view = memoryview(buf)
>>> view.readonly
False
>>> struct.pack_into("<B", view, 0, 88)
Traceback (most recent call last):
File "<input>", line 1, in <module>
TypeError: expected a writeable buffer object
>>> view[0:1] = 'a'
>>> view[0]
'a'
>>> buf[0]
97
>>> chr(buf[0])
'a'
The memoryview is writeable and from what I can tell from the documentation it implements the buffer interface, but struct.pack_into will not use it. |
|
Date |
User |
Action |
Args |
2014-07-31 08:31:12 | stangelandcl | set | recipients:
+ stangelandcl |
2014-07-31 08:31:11 | stangelandcl | set | messageid: <1406795471.99.0.191583556895.issue22113@psf.upfronthosting.co.za> |
2014-07-31 08:31:11 | stangelandcl | link | issue22113 messages |
2014-07-31 08:31:11 | stangelandcl | create | |
|