diff options
author | Andrew Svetlov <andrew.svetlov@gmail.com> | 2012-08-13 09:58:02 (GMT) |
---|---|---|
committer | Andrew Svetlov <andrew.svetlov@gmail.com> | 2012-08-13 09:58:02 (GMT) |
commit | ecd78feb7896239e062b8085c073affb8fd1fafa (patch) | |
tree | 67da5d5da3328eaa42da7e65613a7e3bf978a131 /Doc/library | |
parent | 1ef9caa2a19c6e4675f853be38f7db341e0ba3ec (diff) | |
download | cpython-ecd78feb7896239e062b8085c073affb8fd1fafa.zip cpython-ecd78feb7896239e062b8085c073affb8fd1fafa.tar.gz cpython-ecd78feb7896239e062b8085c073affb8fd1fafa.tar.bz2 |
Issue #15624: clarify newline documentation for open and io.TextIOWrapper
Thanks to Chris Jerdonek
Diffstat (limited to 'Doc/library')
-rw-r--r-- | Doc/library/functions.rst | 27 | ||||
-rw-r--r-- | Doc/library/io.rst | 27 |
2 files changed, 30 insertions, 24 deletions
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index 5d6a5fe..ffc34d8 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -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 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. - - * 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 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 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 index 9aecc7d..09e0501 100644 --- a/Doc/library/io.rst +++ b/Doc/library/io.rst @@ -760,18 +760,21 @@ Text I/O *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. - - * 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 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 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 |