Author tom.pohl
Recipients tom.pohl
Date 2015-08-07.10:18:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1438942688.18.0.266077254276.issue24823@psf.upfronthosting.co.za>
In-reply-to
Content
From the ctypes.create_string_buffer docs:
"""If a bytes object is specified as first argument, the buffer is made one item larger than its length so that the last element in the array is a NUL termination character. An integer can be passed as second argument which allows to specify the size of the array if the length of the bytes should not be used."""

Based on this documentation I would expect a NUL-terminated byte array in any case. However, when I do this

>>> for size in range(5, 2, -1): print(size, ctypes.create_string_buffer(b'123', size).raw)
5 b'123\x00\x00'
4 b'123\x00'
3 b'123'

I get b'123' for size=3 without a NUL. My expectation would be the same exception as I get for create_string_buffer(b'123', 2).
History
Date User Action Args
2015-08-07 10:18:08tom.pohlsetrecipients: + tom.pohl
2015-08-07 10:18:08tom.pohlsetmessageid: <1438942688.18.0.266077254276.issue24823@psf.upfronthosting.co.za>
2015-08-07 10:18:07tom.pohllinkissue24823 messages
2015-08-07 10:18:06tom.pohlcreate