mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
Issue #23099: Closing io.BytesIO with exported buffer is rejected now to
prevent corrupting exported buffer.
This commit is contained in:
commit
32ca3dcb97
5 changed files with 23 additions and 7 deletions
|
@ -578,7 +578,8 @@ than raw I/O does.
|
|||
.. class:: BytesIO([initial_bytes])
|
||||
|
||||
A stream implementation using an in-memory bytes buffer. It inherits
|
||||
:class:`BufferedIOBase`.
|
||||
:class:`BufferedIOBase`. The buffer is discarded when the
|
||||
:meth:`~IOBase.close` method is called.
|
||||
|
||||
The argument *initial_bytes* contains optional initial :class:`bytes` data.
|
||||
|
||||
|
@ -599,7 +600,7 @@ than raw I/O does.
|
|||
|
||||
.. note::
|
||||
As long as the view exists, the :class:`BytesIO` object cannot be
|
||||
resized.
|
||||
resized or closed.
|
||||
|
||||
.. versionadded:: 3.2
|
||||
|
||||
|
@ -607,6 +608,7 @@ than raw I/O does.
|
|||
|
||||
Return :class:`bytes` containing the entire contents of the buffer.
|
||||
|
||||
|
||||
.. method:: read1()
|
||||
|
||||
In :class:`BytesIO`, this is the same as :meth:`read`.
|
||||
|
@ -880,7 +882,8 @@ Text I/O
|
|||
|
||||
.. class:: StringIO(initial_value='', newline='\\n')
|
||||
|
||||
An in-memory stream for text I/O.
|
||||
An in-memory stream for text I/O. The text buffer is discarded when the
|
||||
:meth:`~IOBase.close` method is called.
|
||||
|
||||
The initial value of the buffer (an empty string by default) can be set by
|
||||
providing *initial_value*. The *newline* argument works like that of
|
||||
|
@ -892,9 +895,7 @@ Text I/O
|
|||
|
||||
.. method:: getvalue()
|
||||
|
||||
Return a ``str`` containing the entire contents of the buffer at any
|
||||
time before the :class:`StringIO` object's :meth:`close` method is
|
||||
called.
|
||||
Return a ``str`` containing the entire contents of the buffer.
|
||||
|
||||
Example usage::
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue