-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
Add new StreamReader.readuntil() method #70238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
See code discussion here: |
Sorry, posted my previous message here by mistake (it was for issue bpo-26081). |
New changeset db11d0db1598 by Yury Selivanov in branch '3.4': New changeset a6288fe5420f by Yury Selivanov in branch '3.5': New changeset c2cd3b435afe by Yury Selivanov in branch 'default': |
Leaving this issue open until we have the docs committed. |
Attached patch, but did not compile documentation until text is validated. These descriptions are just copies of docstrings of corresponding functions. |
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 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 ( 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 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, . . . |
Also it looks like the b'\n' default confuses Sphinx. Maybe it needs extra escaping? |
Looks like we already have docs for readuntil. Mark, could you please check if we have some docs missing (or just close the issue)? |
It needs to compare python functoin(s) docstrings with separate documentation. All information from docstrings should also be written in separate docs. Will compare later. |
StreamReader and StreamWriter were merged to Stream with bpo-36889 and there were also docs added for it along with asyncio docs rewritten. I am closing this as fixed. Feel free to reopen if needed. Thanks. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: