summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2015-10-10 02:52:30 (GMT)
committerMartin Panter <vadmium+py@gmail.com>2015-10-10 02:52:30 (GMT)
commitdab305ef059434366e3a0c46533ff3b206e70463 (patch)
tree5a8da3704813e2d8fb7c3c005dbab488e9d0ad47 /Doc
parent462502b08484796d9a4b981aee5becac574ee43a (diff)
downloadcpython-dab305ef059434366e3a0c46533ff3b206e70463.zip
cpython-dab305ef059434366e3a0c46533ff3b206e70463.tar.gz
cpython-dab305ef059434366e3a0c46533ff3b206e70463.tar.bz2
Issue #22413: Document newline effect on StringIO initializer and getvalue
Also add to comment in the C code.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/io.rst17
1 files changed, 12 insertions, 5 deletions
diff --git a/Doc/library/io.rst b/Doc/library/io.rst
index 33cbb7e..6743b27 100644
--- a/Doc/library/io.rst
+++ b/Doc/library/io.rst
@@ -803,10 +803,16 @@ Text I/O
An in-memory stream for unicode text. It inherits :class:`TextIOWrapper`.
- The initial value of the buffer (an empty unicode 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:`TextIOWrapper` and its parents:
@@ -815,7 +821,8 @@ Text I/O
Return a ``unicode`` containing the entire contents of the buffer at any
time before the :class:`StringIO` object's :meth:`close` method is
- called.
+ called. Newlines are decoded as if by :meth:`~TextIOBase.read`,
+ although the stream position is not changed.
Example usage::