Message76880
It's not a memoryview bug, but a bytearray oddity. The bytearray uses a
variable-sized buffer underneath, and it tries to minimize the number of
reallocations when changing the object length through some simple
heuristics. Therefore, a bytearray has both a logical size (the one
which is seen from Python, e.g. len()) and a physical size (which can be
greater than the logical size, due to those heuristics).
The bug here is that the bytearray only prohibits changing the physical
size, not the logical size when there is a buffer pointing to it. This
also explains the "\00" you are witnessing at the 5th byte when calling
tobytes() on the memoryview object: it is the end-of-string marker which
has been inserted when changing the logical size. |
|
Date |
User |
Action |
Args |
2008-12-04 12:25:43 | pitrou | set | recipients:
+ pitrou, gumpy |
2008-12-04 12:25:43 | pitrou | set | messageid: <1228393543.18.0.876505915924.issue4509@psf.upfronthosting.co.za> |
2008-12-04 12:25:42 | pitrou | link | issue4509 messages |
2008-12-04 12:25:40 | pitrou | create | |
|