Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Reserving binary Buffer for struct.pack_into() of exact length

1 view
Skip to first unread message

Hans Müller

unread,
Mar 19, 2010, 2:46:45 PM3/19/10
to
Hello,

I need some buffers, which are beeing concatenated an then send via
the socket() function.
My problem is that create_string_buffer() creates a buffer which ist
one byte too long (for a \0 char). But when I concatenate some of
these buffers to a long one to be transfered, the extra byte is
corrupting the resulting buffer.
Of course I could slice the buffer before being concatended, but
this looks ugly to me.
Is there a way to create a writeable buffer object without the \0 byte ?

Thanks a lot

Hans

Emile van Sebille

unread,
Mar 19, 2010, 4:33:00 PM3/19/10
to pytho...@python.org
On 3/19/2010 11:46 AM Hans Müller said...

>>> p = create_string_buffer(5)
>>> p.raw='hello'
>>> p.value
'hello'

0 new messages