GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-80050: Update BufferedReader.read docs around non-blocking by cmaloney · Pull Request #130653 · python/cpython Conversation
|
|
cc: @gpshead |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| 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 |
There was an error while loading. Please reload this page.
There was a problem 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
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.
There was an error while loading. Please reload this page.
…ythonGH-130653) (cherry picked from commit e1f8914) Co-authored-by: Cody Maloney <[email protected]>
|
Sorry, @cmaloney and @gpshead, I could not cleanly backport this to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
GH-134444 is a backport of this pull request to the 3.14 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…cking (pythonGH-130653) (cherry picked from commit e1f8914) Co-authored-by: Cody Maloney <[email protected]>
|
GH-134445 is a backport of this pull request to the 3.13 branch. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…H-130653) (#134445) (cherry picked from commit e1f8914) Co-authored-by: Cody Maloney <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.