[issue27261] io.BytesIO.truncate does not work as advertised

2018-10-12 Thread Anton Barkovsky


Anton Barkovsky  added the comment:

I'm willing to try to fix this behavior.

I just want to check that this would not be considered breaking backwards 
compatibility. I can imagine in theory some code relying on it, but I would say 
that it would be relying on a bug. If some code is passed BytesIO in place of a 
file, then the current behavior is clearly undesirable. If some code 
specifically uses BytesIO and relies on this... I guess this can happen, but 
should be very rare and contrary to widely documented behavior. So it seems ok 
to just fix this, but I'm not very familiar with how such changes are usually 
handled in cPython, so I'd like to get approval from someone experienced.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27261] io.BytesIO.truncate does not work as advertised

2018-10-12 Thread Anton Barkovsky


Change by Anton Barkovsky :


--
nosy: +anton.barkovsky

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27261] io.BytesIO.truncate does not work as advertised

2018-09-23 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +xtreak

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27261] io.BytesIO.truncate does not work as advertised

2016-06-08 Thread Justus Winter

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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27261] io.BytesIO.truncate does not work as advertised

2016-06-07 Thread Xiang Zhang

Changes by Xiang Zhang :


--
nosy: +alexandre.vassalotti, serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27261] io.BytesIO.truncate does not work as advertised

2016-06-07 Thread Xiang Zhang

Xiang Zhang added the comment:

Is this a bug or a documentation matter? Inspecting BytesIO.truncate's code, it 
does resizing similar to list, this seems to be a designed feature, which 
conflicts with the documented behaviour.

--
nosy: +xiang.zhang

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27261] io.BytesIO.truncate does not work as advertised

2016-06-07 Thread Martin Panter

Martin Panter added the comment:

BytesIO is supposed to implement IOBase. I would treat this as a bug in 
existing versions too.

--
nosy: +martin.panter
stage:  -> needs patch
versions: +Python 2.7, Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27261] io.BytesIO.truncate does not work as advertised

2016-06-07 Thread Justus Winter

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: expected length 42, got 0

The documentation [0] says that truncate can extend objects, and there is no 
indication that BytesIO does not support that.  As demonstrated, truncate 
returns the new size, but the buffer obtained from that BytesIO is of size zero 
(likewise, b.getvalue() returns b''.

0: https://docs.python.org/3.6/library/io.html#io.IOBase.truncate

--
components: IO, Library (Lib)
messages: 267748
nosy: justus.winter
priority: normal
severity: normal
status: open
title: io.BytesIO.truncate does not work as advertised
type: behavior
versions: Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com