Message248183
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). |
|
Date |
User |
Action |
Args |
2015-08-07 10:18:08 | tom.pohl | set | recipients:
+ tom.pohl |
2015-08-07 10:18:08 | tom.pohl | set | messageid: <1438942688.18.0.266077254276.issue24823@psf.upfronthosting.co.za> |
2015-08-07 10:18:07 | tom.pohl | link | issue24823 messages |
2015-08-07 10:18:06 | tom.pohl | create | |
|