mirror of
https://github.com/python/cpython.git
synced 2025-11-11 14:44:57 +00:00
Make TextIOWrapper's documentation clearer by copying the newline argument's description from open().
This commit is contained in:
commit
3c25dfbf13
2 changed files with 32 additions and 17 deletions
|
|
@ -767,14 +767,22 @@ Text I/O
|
||||||
sequences) can be used. Any other error handling name that has been
|
sequences) can be used. Any other error handling name that has been
|
||||||
registered with :func:`codecs.register_error` is also valid.
|
registered with :func:`codecs.register_error` is also valid.
|
||||||
|
|
||||||
*newline* can be ``None``, ``''``, ``'\n'``, ``'\r'``, or ``'\r\n'``. It
|
*newline* controls how line endings are handled. It can be ``None``,
|
||||||
controls the handling of line endings. If it is ``None``, universal newlines
|
``''``, ``'\n'``, ``'\r'``, and ``'\r\n'``. It works as follows:
|
||||||
is enabled. With this enabled, on input, the lines endings ``'\n'``,
|
|
||||||
``'\r'``, or ``'\r\n'`` are translated to ``'\n'`` before being returned to
|
* On input, if *newline* is ``None``, universal newlines mode is enabled.
|
||||||
the caller. Conversely, on output, ``'\n'`` is translated to the system
|
Lines in the input can end in ``'\n'``, ``'\r'``, or ``'\r\n'``, and these
|
||||||
default line separator, :data:`os.linesep`. If *newline* is any other of its
|
are translated into ``'\n'`` before being returned to the caller. If it is
|
||||||
legal values, that newline becomes the newline when the file is read and it
|
``''``, universal newline mode is enabled, but line endings are returned to
|
||||||
is returned untranslated. On output, ``'\n'`` is converted to the *newline*.
|
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 ``''``, 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
|
If *line_buffering* is ``True``, :meth:`flush` is implied when a call to
|
||||||
write contains a newline character.
|
write contains a newline character.
|
||||||
|
|
|
||||||
|
|
@ -635,15 +635,22 @@ PyDoc_STRVAR(textiowrapper_doc,
|
||||||
"errors determines the strictness of encoding and decoding (see the\n"
|
"errors determines the strictness of encoding and decoding (see the\n"
|
||||||
"codecs.register) and defaults to \"strict\".\n"
|
"codecs.register) and defaults to \"strict\".\n"
|
||||||
"\n"
|
"\n"
|
||||||
"newline can be None, '', '\\n', '\\r', or '\\r\\n'. It controls the\n"
|
"newline controls how line endings are handled. It can be None, '',\n"
|
||||||
"handling of line endings. If it is None, universal newlines is\n"
|
"'\\n', '\\r', and '\\r\\n'. It works as follows:\n"
|
||||||
"enabled. With this enabled, on input, the lines endings '\\n', '\\r',\n"
|
"\n"
|
||||||
"or '\\r\\n' are translated to '\\n' before being returned to the\n"
|
"* On input, if newline is None, universal newlines mode is\n"
|
||||||
"caller. Conversely, on output, '\\n' is translated to the system\n"
|
" enabled. Lines in the input can end in '\\n', '\\r', or '\\r\\n', and\n"
|
||||||
"default line separator, os.linesep. If newline is any other of its\n"
|
" these are translated into '\\n' before being returned to the\n"
|
||||||
"legal values, that newline becomes the newline when the file is read\n"
|
" caller. If it is '', universal newline mode is enabled, but line\n"
|
||||||
"and it is returned untranslated. On output, '\\n' is converted to the\n"
|
" endings are returned to the caller untranslated. If it has any of\n"
|
||||||
"newline.\n"
|
" the other legal values, input lines are only terminated by the given\n"
|
||||||
|
" string, and the line ending is returned to the caller untranslated.\n"
|
||||||
|
"\n"
|
||||||
|
"* On output, if newline is None, any '\\n' characters written are\n"
|
||||||
|
" translated to the system default line separator, os.linesep. If\n"
|
||||||
|
" newline is '', no translation takes place. If newline is any of the\n"
|
||||||
|
" other legal values, any '\\n' characters written are translated to\n"
|
||||||
|
" the given string.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"If line_buffering is True, a call to flush is implied when a call to\n"
|
"If line_buffering is True, a call to flush is implied when a call to\n"
|
||||||
"write contains a newline character."
|
"write contains a newline character."
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue