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

Conversation

@cmaloney

@cmaloney cmaloney commented Feb 27, 2025 •
edited by github-actions Bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Synchronize io.BufferedReader and io.BufferedIOBase documentation with the current implementation. Focused on behavior around non-blocking streams.

  • Issue: io.BufferReader.read() returns None #80050

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

Sorry, something went wrong.

Uh oh!

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

All reactions
@cmaloney
pythongh-80050: Update BufferedReader.read around non-blocking
4ed4237
Synchronize `io.BufferedReader` and `io.BufferedIOBase` documentation
with the current implementation. Focused on behavior around non-blocking
streams.
@bedevere-app bedevere-app Bot added docs Documentation in the Doc dir skip news awaiting review labels Feb 27, 2025
@github-project-automation github-project-automation Bot added this to Docs PRs Feb 27, 2025
@github-project-automation github-project-automation Bot moved this to Todo in Docs PRs Feb 27, 2025
@bedevere-app bedevere-app Bot mentioned this pull request Feb 27, 2025
io.BufferReader.read() returns None #80050
Closed
@cmaloney cmaloney changed the title gh-80050: Update BufferedReader.read around non-blocking gh-80050: Update BufferedReader.read docs around non-blocking Feb 27, 2025
cmaloney added 5 commits February 27, 2025 12:30
@cmaloney
Tweaks around raw.readall
b87870b
@cmaloney
tweak readall, hopefully passes
2119f78
@cmaloney
tweaks
ec7f023
@cmaloney
clss -> class
11b754d
@cmaloney
grammatical tweaking
b6d319b
@cmaloney cmaloney mentioned this pull request Mar 1, 2025
gh-129011: Update comments in FileIO to match current code #129012
Merged
cmaloney
cmaloney commented Mar 7, 2025
View reviewed changes
Comment thread Doc/library/io.rst Resolved

Uh oh!

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

cmaloney added 5 commits March 11, 2025 16:37
@cmaloney
Update to include behavior around None
59bd2a1
BufferedReader at least just forwards `None` from the underlying stream.

1. `BufferedReader.read(size=10)` `raw.read(size=10)` returns None
2. `BufferedReader.read()` without size, raw implements `readall()` which returns None
3. `BufferedReader.read()` without size, raw doesn't have readall so uses a loop that calls `raw.read()` which returns None.
@cmaloney
tweak
fbbc382
@cmaloney
Tweak read and read1 None and BlockingIOError comments
dea91ab
@cmaloney
in read1 refer to EINTR retrying
7c4ef7e
@cmaloney
fix doc lint around raw.readinto
c637402
cmaloney
cmaloney commented May 9, 2025
View reviewed changes
Comment thread Doc/library/io.rst Resolved

Uh oh!

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

@cmaloney
personal review fixes
22bc9aa
@cmaloney

cmaloney commented May 19, 2025

Copy link
Copy Markdown
Contributor Author

cc: @gpshead

gpshead reacted with eyes emoji
All reactions
  • 👀 1 reaction

Sorry, something went wrong.

Uh oh!

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

gpshead
gpshead reviewed May 19, 2025
View reviewed changes
Comment thread Doc/library/io.rst Resolved

Uh oh!

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

@gpshead gpshead added the sprint label May 19, 2025
@github-project-automation github-project-automation Bot added this to Sprint May 19, 2025
@github-project-automation github-project-automation Bot moved this to Todo in Sprint May 19, 2025
cmaloney added 2 commits May 19, 2025 17:57
@cmaloney
Update BufferedIOBase class doc for non-blocking
1c4a09c
@cmaloney
Include characters_written in BlockingReader
8ea45f3
cmaloney
cmaloney commented May 19, 2025
View reviewed changes
Comment thread Doc/library/io.rst
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

@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
gpshead
gpshead approved these changes May 21, 2025
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels May 21, 2025
@github-project-automation github-project-automation Bot moved this from Todo to In Progress in Sprint May 21, 2025
@gpshead gpshead added needs backport to 3.13 only security fixes needs backport to 3.14 bugs and security fixes labels May 21, 2025
@gpshead
gpshead enabled auto-merge (squash) May 21, 2025 16:02
@gpshead
gpshead merged commit e1f8914 into python:main May 21, 2025
@github-project-automation github-project-automation Bot moved this from Todo to Done in Docs PRs May 21, 2025
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Sprint May 21, 2025
@bedevere-app bedevere-app Bot removed the awaiting merge label May 21, 2025
@miss-islington-app

miss-islington-app Bot commented May 21, 2025

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

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

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 21, 2025
@cmaloney @miss-islington
pythongh-80050: Update BufferedReader.read docs around non-blocking (p…
54a7841
…ythonGH-130653)

(cherry picked from commit e1f8914)

Co-authored-by: Cody Maloney <[email protected]>
@miss-islington-app

miss-islington-app Bot commented May 21, 2025

Copy link
Copy Markdown

Sorry, @cmaloney and @gpshead, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker e1f891414b2329414a6160ed246f5f869a218bfd 3.13
All reactions

Sorry, something went wrong.

Uh oh!

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

@miss-islington-app miss-islington-app Bot assigned gpshead May 21, 2025
@bedevere-app

bedevere-app Bot commented May 21, 2025

Copy link
Copy Markdown

GH-134444 is a backport of this pull request to the 3.14 branch.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label May 21, 2025
@cmaloney
cmaloney deleted the docs_buffferedreader branch May 21, 2025 16:07
@cmaloney cmaloney mentioned this pull request May 21, 2025
The io module doesn't support non-blocking files #57531
Open
gpshead pushed a commit that referenced this pull request May 21, 2025
@miss-islington @cmaloney
[3.14] gh-80050: Update BufferedReader.read docs around non-blocking (G…
df6d9e7
…H-130653) (#134444)

gh-80050: Update BufferedReader.read docs around non-blocking (GH-130653)
(cherry picked from commit e1f8914)

Co-authored-by: Cody Maloney <[email protected]>
gpshead pushed a commit to gpshead/cpython that referenced this pull request May 21, 2025
@cmaloney @gpshead
[3.13] pythongh-80050: Update BufferedReader.read docs around non-blo…
6f42565
…cking (pythonGH-130653)

(cherry picked from commit e1f8914)

Co-authored-by: Cody Maloney <[email protected]>
@bedevere-app

bedevere-app Bot commented May 21, 2025

Copy link
Copy Markdown

GH-134445 is a backport of this pull request to the 3.13 branch.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label May 21, 2025
gpshead added a commit that referenced this pull request May 21, 2025
@gpshead @cmaloney
[3.13] gh-80050: Update BufferedReader.read docs around non-blocking (G…
5ecc39e
…H-130653) (#134445)

(cherry picked from commit e1f8914)

Co-authored-by: Cody Maloney <[email protected]>
lkollar pushed a commit to lkollar/cpython that referenced this pull request May 26, 2025
@cmaloney @lkollar
pythongh-80050: Update BufferedReader.read docs around non-blocking (p…
dbd0da3
…ythonGH-130653)
@cmaloney cmaloney mentioned this pull request Jun 10, 2025
gh-129011: Update docs for Raw I/O read, readinto, and write #135328
Merged
Pranjal095 pushed a commit to Pranjal095/cpython that referenced this pull request Jul 12, 2025
@cmaloney @Pranjal095
pythongh-80050: Update BufferedReader.read docs around non-blocking (p…
fcfea64
…ythonGH-130653)
@moreati moreati mentioned this pull request Jul 16, 2025
parent: avoid early-EOF in sudo bootstrap, wait until full preamble is read mitogen-hq/mitogen#1299
Closed
taegyunkim pushed a commit to taegyunkim/cpython that referenced this pull request Aug 4, 2025
@cmaloney @taegyunkim
pythongh-80050: Update BufferedReader.read docs around non-blocking (p…
f66bd59
…ythonGH-130653)
gostak-dd pushed a commit to gostak-dd/cpython that referenced this pull request Jun 2, 2026
@cmaloney @gostak-dd
pythongh-80050: Update BufferedReader.read docs around non-blocking (p…
547f410
…ythonGH-130653)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@gpshead gpshead gpshead approved these changes

Uh oh!

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

Assignees

@gpshead gpshead

Labels

docs Documentation in the Doc dir skip news sprint

Projects

Docs PRs
Status: Done
Sprint
Archived in project

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

2 participants

@cmaloney @gpshead
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 01402503 — 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.