Kaydet (Commit) e4b1a189 authored tarafından Andrew Svetlov's avatar Andrew Svetlov

Issue #15624: clarify newline documentation for open and io.TextIOWrapper

Thanks to Chris Jerdonek
...@@ -878,18 +878,21 @@ are always available. They are listed here in alphabetical order. ...@@ -878,18 +878,21 @@ are always available. They are listed here in alphabetical order.
mode). It can be ``None``, ``''``, ``'\n'``, ``'\r'``, and ``'\r\n'``. It mode). It can be ``None``, ``''``, ``'\n'``, ``'\r'``, and ``'\r\n'``. It
works as follows: works as follows:
* On input, if *newline* is ``None``, universal newlines mode is enabled. * When reading input from the stream, if *newline* is ``None``,
Lines in the input can end in ``'\n'``, ``'\r'``, or ``'\r\n'``, and these universal newlines mode is enabled. Lines in the input can end
are translated into ``'\n'`` before being returned to the caller. If it is in ``'\n'``, ``'\r'``, or ``'\r\n'``, and these are translated
``''``, universal newline mode is enabled, but line endings are returned to into ``'\n'`` before being returned to the caller. If it is
the caller untranslated. If it has any of the other legal values, input ``''``, universal newline mode is enabled, but line endings are
lines are only terminated by the given string, and the line ending is returned to the caller untranslated. If it has any of the other
returned to the caller untranslated. legal values, input lines are only terminated by the given
string, and the line ending is returned to the caller
* On output, if *newline* is ``None``, any ``'\n'`` characters written are untranslated.
translated to the system default line separator, :data:`os.linesep`. If
*newline* is ``''`` or ``'\n'``, no translation takes place. If *newline* * When writing output to the stream, if *newline* is ``None``, any
is any of the other legal values, any ``'\n'`` characters written are ``'\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. translated to the given string.
If *closefd* is ``False`` and a file descriptor rather than a filename was If *closefd* is ``False`` and a file descriptor rather than a filename was
......
...@@ -770,18 +770,21 @@ Text I/O ...@@ -770,18 +770,21 @@ Text I/O
*newline* controls how line endings are handled. It can be ``None``, *newline* controls how line endings are handled. It can be ``None``,
``''``, ``'\n'``, ``'\r'``, and ``'\r\n'``. It works as follows: ``''``, ``'\n'``, ``'\r'``, and ``'\r\n'``. It works as follows:
* On input, if *newline* is ``None``, universal newlines mode is enabled. * When reading input from the stream, if *newline* is ``None``,
Lines in the input can end in ``'\n'``, ``'\r'``, or ``'\r\n'``, and these universal newlines mode is enabled. Lines in the input can end
are translated into ``'\n'`` before being returned to the caller. If it is in ``'\n'``, ``'\r'``, or ``'\r\n'``, and these are translated
``''``, universal newline mode is enabled, but line endings are returned to into ``'\n'`` before being returned to the caller. If it is
the caller untranslated. If it has any of the other legal values, input ``''``, universal newline mode is enabled, but line endings are
lines are only terminated by the given string, and the line ending is returned to the caller untranslated. If it has any of the other
returned to the caller untranslated. legal values, input lines are only terminated by the given
string, and the line ending is returned to the caller
* On output, if *newline* is ``None``, any ``'\n'`` characters written are untranslated.
translated to the system default line separator, :data:`os.linesep`. If
*newline* is ``''`` or ``'\n'``, no translation takes place. If *newline* * When writing output to the stream, if *newline* is ``None``, any
is any of the other legal values, any ``'\n'`` characters written are ``'\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. translated to the given string.
If *line_buffering* is ``True``, :meth:`flush` is implied when a call to If *line_buffering* is ``True``, :meth:`flush` is implied when a call to
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment