[issue26050] Add new StreamReader.readuntil() method
Martin Panter added the comment: In revision 83450939b106, Yury added some documentation for readuntil(). I am not familiar with this StreamReader class, but maybe Mark or someone else can check if the remaining changes in his patch are still useful. I can suggest some spelling and wording fixes however. Bits in square brackets are my changes. ## read(n=-1): If *n* is zero, return [an] empty ``bytes`` object [immediately (single L)]. If *n* is positive, this function [tries] to read *n* bytes, [but may return less]. If EOF was received before any byte is read, this function returns [an] empty [bytes] object[, otherwise it returns at least one byte]. [The] returned value is not limited [by] [*limit* (add asterisks)], . . . If [the] stream was paused, . . . ## readline(): Read [] from the stream until [a] newline (``b'\n'``) is found. On success, return [the line, which] ends with [a] newline. If only [a] partial line can be read due to EOF, return [an] incomplete line without terminating newline. When EOF was reached [and] no bytes [were] read, [an] empty ``bytes`` object is returned. If [*limit* (add asterisks)] is reached, ValueError will be raised. In that case, if [a] newline was found, [the] complete line including newline will be removed from [the] internal buffer. [Otherwise, the] internal buffer will be cleared. [*Limit* (add asterisks)] is compared against [the length] of the line[, not counting the] newline. If [the] stream was paused, . . . ## readexactly(n): If *n* is zero, return [an] empty bytes object. [The] returned value is not limited by [*limit* (add asterisks)], . . . If [the] stream was paused, . . . ## readuntil(separator=b'\n'): Read [] from the stream until *separator* is found. On success, [the] chunk [of data] and its separator will be removed from [the] internal buffer (i.e. consumed). [The] returned chunk will include [the] separator at the end. [The] configured stream limit is used to [limit the] result. [*Limit* (add asterisks)] means [the maximum] length of [the] chunk . . . If EOF occurs and [a] complete separator [is] still not found, :exc:`IncompleteReadError`(<partial data>, None) will be raised and [the] internal buffer becomes empty. . . . If [the] chunk cannot be read due to [the] limit, :exc:`LimitOverrunError` will be raised and data will be left in [the] internal buffer, . . . If [the] stream was paused, . . . ---------- assignee: -> docs@python components: +Documentation nosy: +docs@python, martin.panter stage: -> patch review _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26050> _______________________________________
participants (1)
-
Martin Panter