[Python-checkins] cpython (3.2): Issue #15624: clarify newline documentation for open and io.TextIOWrapper

andrew.svetlov python-checkins at python.org
Mon Aug 13 12:00:06 CEST 2012


http://hg.python.org/cpython/rev/5b629e9fde61
changeset:   78539:5b629e9fde61
branch:      3.2
parent:      78537:e855e6c26dfb
user:        Andrew Svetlov <andrew.svetlov at gmail.com>
date:        Mon Aug 13 12:58:02 2012 +0300
summary:
  Issue #15624: clarify newline documentation for open and io.TextIOWrapper

Thanks to Chris Jerdonek

files:
  Doc/library/functions.rst |  25 ++++++++++++++-----------
  Doc/library/io.rst        |  25 ++++++++++++++-----------
  2 files changed, 28 insertions(+), 22 deletions(-)


diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -878,18 +878,21 @@
    mode).  It can be ``None``, ``''``, ``'\n'``, ``'\r'``, and ``'\r\n'``.  It
    works as follows:
 
-   * On input, 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``,
+     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.
 
-   * On output, if *newline* is ``None``, any ``'\n'`` characters written are
-     translated to the system default line separator, :data:`os.linesep`.  If
-     *newline* is ``''`` or ``'\n'``, no translation takes place.  If *newline*
-     is any of the other legal values, any ``'\n'`` characters written are
+   * When writing output to the stream, if *newline* is ``None``, any
+     ``'\n'`` characters written are translated to the system default
+     line separator, :data:`os.linesep`.  If *newline* is ``''`` or
+     ``'\n'``, no translation takes place.  If *newline* is any of the
+     other legal values, any ``'\n'`` characters written are
      translated to the given string.
 
    If *closefd* is ``False`` and a file descriptor rather than a filename was
diff --git a/Doc/library/io.rst b/Doc/library/io.rst
--- a/Doc/library/io.rst
+++ b/Doc/library/io.rst
@@ -760,18 +760,21 @@
    *newline* controls how line endings are handled.  It can be ``None``,
    ``''``, ``'\n'``, ``'\r'``, and ``'\r\n'``.  It works as follows:
 
-   * On input, 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``,
+     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.
 
-   * On output, if *newline* is ``None``, any ``'\n'`` characters written are
-     translated to the system default line separator, :data:`os.linesep`.  If
-     *newline* is ``''`` or ``'\n'``, no translation takes place.  If *newline*
-     is any of the other legal values, any ``'\n'`` characters written are
+   * When writing output to the stream, if *newline* is ``None``, any
+     ``'\n'`` characters written are translated to the system default
+     line separator, :data:`os.linesep`.  If *newline* is ``''`` or
+     ``'\n'``, no translation takes place.  If *newline* is any of the
+     other legal values, any ``'\n'`` characters written are
      translated to the given string.
 
    If *line_buffering* is ``True``, :meth:`flush` is implied when a call to

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list