diff options
author | Benjamin Peterson <benjamin@python.org> | 2009-05-01 20:40:59 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2009-05-01 20:40:59 (GMT) |
commit | d2e0c7955f972c8477260e8d9799dd45acd4607b (patch) | |
tree | 1b6ac51c7efa6425c0da52b22ad88163029935b3 /Doc/library/io.rst | |
parent | 155374d95d8ecd235d3a3edd92dd6f6a23d59f11 (diff) | |
download | cpython-d2e0c7955f972c8477260e8d9799dd45acd4607b.zip cpython-d2e0c7955f972c8477260e8d9799dd45acd4607b.tar.gz cpython-d2e0c7955f972c8477260e8d9799dd45acd4607b.tar.bz2 |
implement a detach() method for BufferedIOBase and TextIOBase #5883
Diffstat (limited to 'Doc/library/io.rst')
-rw-r--r-- | Doc/library/io.rst | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/Doc/library/io.rst b/Doc/library/io.rst index c839691..4f6ee5a 100644 --- a/Doc/library/io.rst +++ b/Doc/library/io.rst @@ -361,6 +361,17 @@ I/O Base Classes :class:`BufferedIOBase` provides or overrides these methods in addition to those from :class:`IOBase`: + .. method:: detach() + + Separate the underlying raw stream from the buffer and return it. + + After the raw stream has been detached, the buffer is in an unusable + state. + + Some buffers, like :class:`BytesIO`, do not have the concept of a single + raw stream to return from this method. They raise + :exc:`UnsupportedOperation`. + .. method:: read([n]) Read and return up to *n* bytes. If the argument is omitted, ``None``, or @@ -547,7 +558,9 @@ Buffered Streams *max_buffer_size* is unused and deprecated. - :class:`BufferedRWPair` implements all of :class:`BufferedIOBase`\'s methods. + :class:`BufferedRWPair` implements all of :class:`BufferedIOBase`\'s methods + except for :meth:`~BufferedIOBase.detach`, which raises + :exc:`UnsupportedOperation`. .. class:: BufferedRandom(raw[, buffer_size[, max_buffer_size]]) @@ -588,6 +601,17 @@ Text I/O A string, a tuple of strings, or ``None``, indicating the newlines translated so far. + .. method:: detach() + + Separate the underlying buffer from the :class:`TextIOBase` and return it. + + After the underlying buffer has been detached, the :class:`TextIOBase` is + in an unusable state. + + Some :class:`TextIOBase` implementations, like :class:`StringIO`, may not + have the concept of an underlying buffer and calling this method will + raise :exc:`UnsupportedOperation`. + .. method:: read(n) Read and return at most *n* characters from the stream as a single |