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-60107: avoid `io.RawIOBase.read` from reading into a temporary bytearray by taskevich · Pull Request #138616 · python/cpython Conversation
|
|
Can you indicate how efficient this actually becomes by using |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
While I think this addition is fine, I'm worried that it could change performances a bit. So I would appreciate if we had numbers indicating whether this changed or not the performance (you can look at https://github.com/python/pyperformance for inspiration of how to write benchmarks). By the way, avoid merging main into your branch unless it's meant to fix CI tests. And remove the NEWS entry for now. We'll add it later if needed. If possible, it would be good if we also had tests where we have a class inheriting from RawIOBase and which tries to mess with the buffer passed to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
…2Y.rst Co-authored-by: Bénédikt Tran <[email protected]>
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.
should we also consider adding some extra unit tests for this change?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This was already mentioned:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| self.assertEqual(rawio.read(2), b"") | ||
|
|
||
| def test_exact_RawIOBase(self): | ||
| rawio = self.MockRawIOWithoutRead((b"ab", b"cd")) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Maybe I wasn't precise enough. RawIOBase.read() is implemented in terms of readinto. So, what we want to do is provide a readinto method that does something bad as it's given the internal buffer we constructed in C. I don't know if it's possible to cause a segfault on main with that approach though.
Stated otherwise, we want some class:
class EvilReadInto(MockRawIOWithoutRead): def readinto(self, buf): # do something bad with 'buf'
And then
r = EvilReadInto(something_here) r.read() # on main, this call should crash, but not with this patch
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I'm going to convert it into a draft until a regression can be found between main and this PR. IOW, we want to be able to do something evil with the buffer we are given in |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for the pull request @taskevich ! A slightly different fix for this has landed in #141532 so going to close this one. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
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.