New submission from Armin Rigo <ar...@users.sourceforge.net>:

The behavior (tested in 3.6 and 3.9) of io.BytesIO().getbuffer() gives a 
unexpected exception message:

>>> b = io.BytesIO()
>>> b.write(b'abc')
3
>>> buf = b.getbuffer()
>>> b.seek(0)
0
>>> b.write(b'?')     # or anything up to 3 bytes
BufferError: Existing exports of data: object cannot be re-sized

The error message pretends that the problem is in resizing the BytesIO object, 
but the write() is not actually causing any resize.

I am not sure if the bug is a wrong error message (and all writes are supposed 
to be forbidden) or a wrongly forbidden write() (after all, we can use the 
buffer itself to write into the same area of memory).

----------
components: Interpreter Core
messages: 372237
nosy: arigo
priority: normal
severity: normal
stage: test needed
status: open
title: confusing BufferError: Existing exports of data: object cannot be 
re-sized
type: behavior

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue41097>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to