summaryrefslogtreecommitdiff
path: root/Doc/library/io.rst
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2012-08-15 11:11:27 -0400
committerR David Murray <rdmurray@bitdance.com>2012-08-15 11:11:27 -0400
commit27bbcfb8ff55ed2c57042bf72eb2ba01ec7e4169 (patch)
treed4a7886a29e92e4811c1087086aa30e1c27eb586 /Doc/library/io.rst
parent592df20efcc41d2448c8acc35b3b4f15aa5c0bf2 (diff)
parentee0a945ae4077d9e4ffdb77e247ed13265316897 (diff)
downloadcpython-git-27bbcfb8ff55ed2c57042bf72eb2ba01ec7e4169.tar.gz
Merge #15543: glossary entry for and 'universal newlines', and links to it.
Patch by Chris Jerdonek.
Diffstat (limited to 'Doc/library/io.rst')
-rw-r--r--Doc/library/io.rst25
1 files changed, 16 insertions, 9 deletions
diff --git a/Doc/library/io.rst b/Doc/library/io.rst
index f6327523dc..3a8ddd00d0 100644
--- a/Doc/library/io.rst
+++ b/Doc/library/io.rst
@@ -768,16 +768,20 @@ Text I/O
sequences) can be used. Any other error handling name that has been
registered with :func:`codecs.register_error` is also valid.
+ .. index::
+ single: universal newlines; io.TextIOWrapper class
+
*newline* controls how line endings are handled. It can be ``None``,
``''``, ``'\n'``, ``'\r'``, and ``'\r\n'``. It works as follows:
- * When reading input from the stream, if *newline* is ``None``, universal
- newlines mode is enabled. Lines in the input can end in ``'\n'``,
- ``'\r'``, or ``'\r\n'``, and these are translated into ``'\n'`` before
- being returned to the caller. If it is ``''``, universal newline mode is
- enabled, but line endings are returned to the caller untranslated. If it
- has any of the other legal values, input lines are only terminated by the
- given string, and the line ending is returned to the caller untranslated.
+ * When reading input from the stream, if *newline* is ``None``,
+ :term:`universal newlines` mode is enabled. Lines in the input can end in
+ ``'\n'``, ``'\r'``, or ``'\r\n'``, and these are translated into ``'\n'``
+ before being returned to the caller. If it is ``''``, universal newlines
+ mode is enabled, but line endings are returned to the caller untranslated.
+ If it has any of the other legal values, input lines are only terminated
+ by the given string, and the line ending is returned to the caller
+ untranslated.
* When writing output to the stream, if *newline* is ``None``, any ``'\n'``
characters written are translated to the system default line separator,
@@ -843,10 +847,13 @@ Text I/O
output.close()
+.. index::
+ single: universal newlines; io.IncrementalNewlineDecoder class
+
.. class:: IncrementalNewlineDecoder
- A helper codec that decodes newlines for universal newlines mode. It
- inherits :class:`codecs.IncrementalDecoder`.
+ A helper codec that decodes newlines for :term:`universal newlines` mode.
+ It inherits :class:`codecs.IncrementalDecoder`.
Performance