New submission from Christoph Anton Mitterer calestyo@scientia.org:
Hey.
It would be nice if the following behaviour could be definitely clarified:
When reading from a text stream with readline(size) with a n > 0size it says: "If size is specified, at most size characters will be read."
Also, depending on the settings of newlines of the stream, \r\n would be converted to \n.
It's not definitely clear whether a string like "abc\r\n" read with a size of = 4 will return "abc\n" (which it seems to do, in other words, it reads actually 5 characters, but sill returns only 4), or whether it returns "abc\r".
Cheers, Chris.
---------- assignee: docs@python components: Documentation messages: 387758 nosy: calestyo, docs@python priority: normal severity: normal status: open title: document whether io.TextIOBase.readline(size>0) will always read the full newline
_______________________________________ Python tracker report@bugs.python.org https://bugs.python.org/issue43336 _______________________________________
Christoph Anton Mitterer calestyo@scientia.org added the comment:
"a n > 0size" should have read "a size > 0"
----------
_______________________________________ Python tracker report@bugs.python.org https://bugs.python.org/issue43336 _______________________________________
Change by Terry J. Reedy tjreedy@udel.edu:
---------- nosy: +benjamin.peterson
_______________________________________ Python tracker report@bugs.python.org https://bugs.python.org/issue43336 _______________________________________
Christoph Anton Mitterer calestyo@scientia.org added the comment:
I guess that the translation from CRLF to LF simply happens before the size restriction is enforced (which is good so, btw), so effectively it:
will not *read* at most size characters from the stream, but *return* at most size characters from it (with any newlines translated before, and thus more characters read from the stream than returned)
----------
_______________________________________ Python tracker report@bugs.python.org https://bugs.python.org/issue43336 _______________________________________