summaryrefslogtreecommitdiffstats
path: root/Doc/library/io.rst
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2015-10-10 03:01:20 (GMT)
committerMartin Panter <vadmium+py@gmail.com>2015-10-10 03:01:20 (GMT)
commitcfad54344f570c1e833d92289ac571da7315b164 (patch)
treefe27ffbbeac5a45428586ef8ab97409971a42bf7 /Doc/library/io.rst
parente44dba3b4f9371be10c0b9414e6401a4d95184d5 (diff)
downloadcpython-cfad54344f570c1e833d92289ac571da7315b164.zip
cpython-cfad54344f570c1e833d92289ac571da7315b164.tar.gz
cpython-cfad54344f570c1e833d92289ac571da7315b164.tar.bz2
Issue #22413: Document newline effect on StringIO initializer and getvalue
Also add to comment in the C code.
Diffstat (limited to 'Doc/library/io.rst')
-rw-r--r--Doc/library/io.rst16
1 files changed, 12 insertions, 4 deletions
diff --git a/Doc/library/io.rst b/Doc/library/io.rst
index 9b12045..592bc48 100644
--- a/Doc/library/io.rst
+++ b/Doc/library/io.rst
@@ -864,10 +864,16 @@ 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
- :class:`TextIOWrapper`. The default is to consider only ``\n`` characters
- as end of lines and to do no newline translation.
+ The initial value of the buffer can be set by providing *initial_value*.
+ If newline translation is enabled, newlines will be encoded as if by
+ :meth:`~TextIOBase.write`. The stream is positioned at the start of
+ the buffer.
+
+ The *newline* argument works like that of :class:`TextIOWrapper`.
+ The default is to consider only ``\n`` characters as ends of lines and
+ to do no newline translation. If *newline* is set to ``None``,
+ newlines are written as ``\n`` on all platforms, but universal
+ newline decoding is still performed when reading.
:class:`StringIO` provides this method in addition to those from
:class:`TextIOBase` and its parents:
@@ -875,6 +881,8 @@ Text I/O
.. method:: getvalue()
Return a ``str`` containing the entire contents of the buffer.
+ Newlines are decoded as if by :meth:`~TextIOBase.read`, although
+ the stream position is not changed.
Example usage::