GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-80050: Update BufferedReader.read docs around non-blocking by cmaloney · Pull Request #130653 · python/cpython

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.

Sign up for GitHub

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

Merged
gpshead merged 15 commits into python:main from cmaloney:docs_buffferedreader
May 21, 2025

Uh oh!

There was an error while loading. Please reload this page.

Merged

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

Changes from 1 commit
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
4ed4237
gh-80050: Update BufferedReader.read around non-blocking
cmaloney Feb 27, 2025
b87870b
Tweaks around raw.readall
cmaloney Feb 27, 2025
2119f78
tweak readall, hopefully passes
cmaloney Feb 27, 2025
ec7f023
tweaks
cmaloney Feb 27, 2025
11b754d
clss -> class
cmaloney Feb 28, 2025
b6d319b
grammatical tweaking
cmaloney Feb 28, 2025
59bd2a1
Update to include behavior around None
cmaloney Mar 11, 2025
fbbc382
tweak
cmaloney Mar 11, 2025
dea91ab
Tweak read and read1 None and BlockingIOError comments
cmaloney Mar 13, 2025
7c4ef7e
in read1 refer to EINTR retrying
cmaloney Mar 13, 2025
c637402
fix doc lint around raw.readinto
cmaloney Mar 13, 2025
22bc9aa
personal review fixes
cmaloney May 13, 2025
1c4a09c
Update BufferedIOBase class doc for non-blocking
cmaloney May 19, 2025
8ea45f3
Include characters_written in BlockingReader
cmaloney May 19, 2025
45bb912
Fewer rather than Less
gpshead May 21, 2025
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
Prev Previous commit
Next Next commit
Include characters_written in BlockingReader
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@cmaloney
cmaloney committed May 19, 2025
commit 8ea45f3ab08147b8faf66dedd21e2bc7c3404915

There are no files selected for viewing

4 changes: 2 additions & 2 deletions 4 Doc/library/io.rst
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -823,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
Comment thread

@cmaloney cmaloney May 19, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

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

cpython/Lib/test/test_io.py

Lines 1918 to 1943 in a7f317d

def test_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")
except self.BlockingIOError as e:
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)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
is raised if the buffer needs to be written out but the raw stream blocks.


.. class:: BufferedRandom(raw, buffer_size=DEFAULT_BUFFER_SIZE)
Expand Down
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.