Repository navigation
gh-158952: Reject read-only buffers before reading in _pyio #158953
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
eedc052
3831e0c
a7d0e02
f46989f
5c5f966
e1f76eb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -568,6 +568,21 @@ def test_readinto(self): | |
| memio.readinto(b) | ||
| self.assertEqual(b, b"") | ||
|
|
||
| def test_readinto_readonly_buffer(self): | ||
| data = b"abcdef" | ||
| for method in ("readinto", "readinto1"): | ||
| for buffer in (b"xxx", memoryview(b"xxx"), | ||
| b"", memoryview(b"")): | ||
|
Member
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. Use
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. Updated the test to use |
||
| for position in (0, 4, 10): | ||
| with self.subTest(method=method, buffer=buffer, | ||
| position=position): | ||
| with self.ioclass(data) as memio: | ||
| memio.seek(position) | ||
| with self.assertRaises(TypeError): | ||
| getattr(memio, method)(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) | ||
|
|
||
| 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. |
Uh oh!
There was an error while loading. Please reload this page.