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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Include characters_written in BlockingReader
  • Loading branch information
@cmaloney
cmaloney committedMay 19, 2025
commit8ea45f3ab08147b8faf66dedd21e2bc7c3404915
4 changes: 2 additions & 2 deletionsDoc/library/io.rst
View file
Open in desktop
Original file line numberDiff line numberDiff 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
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)

is raised if the buffer needs to be written out butthe raw stream blocks.


.. class:: BufferedRandom(raw, buffer_size=DEFAULT_BUFFER_SIZE)
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp