Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-80050: Update BufferedReader.read docs around non-blocking#130653

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
gpshead merged 15 commits intopython:mainfromcmaloney:docs_buffferedreader
May 21, 2025

Conversation

cmaloney
Copy link
Contributor

@cmaloneycmaloney commentedFeb 27, 2025
edited by github-actionsbot
Loading

Synchronizeio.BufferedReader andio.BufferedIOBase documentation with the current implementation. Focused on behavior around non-blocking streams.


📚 Documentation preview 📚:https://cpython-previews--130653.org.readthedocs.build/

Synchronize `io.BufferedReader` and `io.BufferedIOBase` documentationwith the current implementation. Focused on behavior around non-blockingstreams.
@bedevere-appbedevere-appbot added docsDocumentation in the Doc dir skip news awaiting review labelsFeb 27, 2025
@cmaloneycmaloney changed the titlegh-80050: Update BufferedReader.read around non-blockinggh-80050: Update BufferedReader.read docs around non-blockingFeb 27, 2025
BufferedReader at least just forwards `None` from the underlying stream.1. `BufferedReader.read(size=10)` `raw.read(size=10)` returns None2. `BufferedReader.read()` without size, raw implements `readall()` which returns None3. `BufferedReader.read()` without size, raw doesn't have readall so uses a loop that calls `raw.read()` which returns None.
@cmaloney
Copy link
ContributorAuthor

cc:@gpshead

gpshead reacted with eyes emoji

@@ -826,8 +823,8 @@ than raw I/O does.

Write the :term:`bytes-like object`, *b*, and return the
number of bytes written. When in non-blocking mode, a
:exc:`BlockingIOError` is raised if the buffer needs to be written out but
the raw stream blocks.
:exc:`BlockingIOError` with :attr:`BlockingIOError.characters_written` set
Copy link
ContributorAuthor

@cmaloneycmaloneyMay 19, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

characters_written is fairly well tested in this case

deftest_write_non_blocking(self):
raw=self.MockNonBlockWriterIO()
bufio=self.tp(raw,8)
self.assertEqual(bufio.write(b"abcd"),4)
self.assertEqual(bufio.write(b"efghi"),5)
# 1 byte will be written, the rest will be buffered
raw.block_on(b"k")
self.assertEqual(bufio.write(b"jklmn"),5)
# 8 bytes will be written, 8 will be buffered and the rest will be lost
raw.block_on(b"0")
try:
bufio.write(b"opqrwxyz0123456789")
exceptself.BlockingIOErrorase:
written=e.characters_written
else:
self.fail("BlockingIOError should have been raised")
self.assertEqual(written,16)
self.assertEqual(raw.pop_written(),
b"abcdefghijklmnopqrwxyz")
self.assertEqual(bufio.write(b"ABCDEFGHI"),9)
s=raw.pop_written()
# Previously buffered bytes were flushed
self.assertTrue(s.startswith(b"01234567A"),s)

@github-project-automationgithub-project-automationbot moved this fromTodo toIn Progress inSprint 2024May 21, 2025
@gpsheadgpshead added needs backport to 3.13bugs and security fixes needs backport to 3.14bugs and security fixes labelsMay 21, 2025
@gpsheadgpsheadenabled auto-merge (squash)May 21, 2025 16:02
@gpsheadgpshead merged commite1f8914 intopython:mainMay 21, 2025
31 of 32 checks passed
@github-project-automationgithub-project-automationbot moved this fromTodo toDone inDocs PRsMay 21, 2025
@github-project-automationgithub-project-automationbot moved this fromIn Progress toDone inSprint 2024May 21, 2025
@miss-islington-app
Copy link

Thanks@cmaloney for the PR, and@gpshead for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestMay 21, 2025
…ythonGH-130653)(cherry picked from commite1f8914)Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
@miss-islington-app
Copy link

Sorry,@cmaloney and@gpshead, I could not cleanly backport this to3.13 due to a conflict.
Please backport usingcherry_picker on command line.

cherry_picker e1f891414b2329414a6160ed246f5f869a218bfd 3.13

@bedevere-app
Copy link

GH-134444 is a backport of this pull request to the3.14 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.14bugs and security fixes labelMay 21, 2025
@cmaloneycmaloney deleted the docs_buffferedreader branchMay 21, 2025 16:07
gpshead pushed a commit that referenced this pull requestMay 21, 2025
…H-130653) (#134444)gh-80050: Update BufferedReader.read docs around non-blocking (GH-130653)(cherry picked from commite1f8914)Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
gpshead pushed a commit to gpshead/cpython that referenced this pull requestMay 21, 2025
…cking (pythonGH-130653)(cherry picked from commite1f8914)Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
@bedevere-app
Copy link

GH-134445 is a backport of this pull request to the3.13 branch.

@bedevere-appbedevere-appbot removed the needs backport to 3.13bugs and security fixes labelMay 21, 2025
gpshead added a commit that referenced this pull requestMay 21, 2025
…H-130653) (#134445)(cherry picked from commite1f8914)Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@gpsheadgpsheadgpshead approved these changes

Assignees

@gpsheadgpshead

Labels
docsDocumentation in the Doc dirskip newssprint
Projects
Status: Done
Status: Done
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@cmaloney@gpshead

[8]ページ先頭

©2009-2025 Movatter.jp