Justus Winter added the comment:
FWIW, I consider the documented behavior a feature. My use case is to allocate
a BytesIO object with a given size, obtain a view to its buffer, and write to
it from a c library.
--
___
Python tracker <
New submission from Justus Winter:
% python3.6 -c "import io; b=io.BytesIO(); assert b.truncate(42) == 42; assert
len(b.getbuffer()) == 42, 'expected length 42, got
{}'.format(len(b.getbuffer()))"
Traceback (most recent call last):
File "", line 1, in
AssertionError: exp