This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author stangelandcl
Recipients stangelandcl
Date 2014-07-31.08:31:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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]
>>> view = memoryview(buf)
>>> view.readonly
>>> 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]
>>> buf[0]
>>> chr(buf[0])

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:12stangelandclsetrecipients: + stangelandcl
2014-07-31 08:31:11stangelandclsetmessageid: <>
2014-07-31 08:31:11stangelandcllinkissue22113 messages
2014-07-31 08:31:11stangelandclcreate