| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -568,6 +568,20 @@ def test_readinto(self): | |
| memio.readinto(b) | ||
| self.assertEqual(b, b"") | ||
|
|
||
| @support.subTests("method", ("readinto", "readinto1")) | ||
| @support.subTests("buffer", ( | ||
| b"xxx", memoryview(b"xxx"), b"", memoryview(b""), | ||
| )) | ||
| @support.subTests("position", (0, 4, 10)) | ||
| def test_readinto_readonly_buffer(self, method, buffer, position): | ||
|
Comment thread
Copy link
Copy Markdown
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI think this would fit better in test_bufferedio. Goal for me is to test all the Buffered I/O implementations readinto a readonly buffer doesn't advance. That the others implement it right already is nice, but a good thing to make sure we keep. test_general IOTest would also work well as a spot but I don't like it quite as much just because it keeps adding to the big ball of general tests.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThanks! Added a shared test in BufferedReaderTest in f46989f, covering both BufferedReader and BufferedRandom in the C and Python implementations. It checks readinto and readinto1, readonly bytes and memoryviews, and both prefilled and unfilled read buffers. The test verifies that the failed call preserves the logical position and subsequent readable data. I retained the BytesIO regression test to cover the original bug directly. The shared test uses nonempty targets with data remaining: the Python buffered readers currently return 0 for empty targets or at EOF, whereas the C implementations reject them. The existing BytesIO regression still covers those edge cases. The full test_io suite passes (1,047 tests, 35 skipped).
Sorry, something went wrong.
cmaloney reacted with thumbs up emoji
All reactions
|
||
| data = b"abcdef" | ||
| with self.ioclass(data) as memio: | ||
| memio.seek(position) | ||
| op = getattr(memio, method) | ||
| self.assertRaises(TypeError, op, buffer) | ||
| self.assertEqual(memio.tell(), position) | ||
| self.assertEqual(memio.read(), data[position:]) | ||
|
|
||
| def test_relative_seek(self): | ||
| buf = self.buftype("1234567890") | ||
| memio = self.ioclass(buf) | ||
| Expand Down | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| The pure Python implementation of :meth:`io.BufferedIOBase.readinto` and | ||
| :meth:`~io.BufferedIOBase.readinto1` now rejects read-only buffers before | ||
| reading input, without changing the stream position. |
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.