File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -889,17 +889,25 @@ Text I/O
889889 An in-memory stream for text I/O. The text buffer is discarded when the
890890 :meth: `~IOBase.close ` method is called.
891891
892- The initial value of the buffer (an empty string by default) can be set by
893- providing *initial_value *. The *newline * argument works like that of
894- :class: `TextIOWrapper `. The default is to consider only ``\n `` characters
895- as end of lines and to do no newline translation.
892+ The initial value of the buffer can be set by providing *initial_value *.
893+ If newline translation is enabled, newlines will be encoded as if by
894+ :meth: `~TextIOBase.write `. The stream is positioned at the start of
895+ the buffer.
896+
897+ The *newline * argument works like that of :class: `TextIOWrapper `.
898+ The default is to consider only ``\n `` characters as ends of lines and
899+ to do no newline translation. If *newline * is set to ``None ``,
900+ newlines are written as ``\n `` on all platforms, but universal
901+ newline decoding is still performed when reading.
896902
897903 :class: `StringIO ` provides this method in addition to those from
898904 :class: `TextIOBase ` and its parents:
899905
900906 .. method :: getvalue()
901907
902908 Return a ``str `` containing the entire contents of the buffer.
909+ Newlines are decoded as if by :meth: `~TextIOBase.read `, although
910+ the stream position is not changed.
903911
904912 Example usage::
905913
Original file line number Diff line number Diff line change @@ -52,7 +52,12 @@ extern PyObject *_PyIncrementalNewlineDecoder_decode(
5252 which can be safely put aside until another search.
5353
5454 NOTE: for performance reasons, `end` must point to a NUL character ('\0').
55- Otherwise, the function will scan further and return garbage. */
55+ Otherwise, the function will scan further and return garbage.
56+
57+ There are three modes, in order of priority:
58+ * translated: Only find \n (assume newlines already translated)
59+ * universal: Use universal newlines algorithm
60+ * Otherwise, the line ending is specified by readnl, a str object */
5661extern Py_ssize_t _PyIO_find_line_ending (
5762 int translated , int universal , PyObject * readnl ,
5863 int kind , char * start , char * end , Py_ssize_t * consumed );
You can’t perform that action at this time.
0 commit comments