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
bpo-35210: Use bytes + memoryview + resize instead of bytesarray + array in io.RawIOBase.read #10451
Conversation
74aef85
to
641c14a
Compare
…tes in io.RawIOBase.read
| @@ -0,0 +1,2 @@ | |||
| Use bytes + memoryview + resize instead of bytesarray + bytes in | |||
| io.RawIOBase.read | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| io.RawIOBase.read | |
| :meth:`io.RawIOBase.read`. |
I think this news entry is a little too vague.
| if (newn < n) { | ||
| if (refcnt == 1) { | ||
| _PyBytes_Resize(&b, newn); | ||
| } else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to PEP 7, the } should be by itself on the previous line (https://www.python.org/dev/peps/pep-0007/#code-lay-out).
| } else { | |
| } | |
| else { |
| } else if (newn == n) { | ||
| return b; | ||
| } else { | ||
| PyErr_SetString(PyExc_RuntimeError, "readinto() returned bad value"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think RuntimeError should be used here.
| @@ -898,36 +898,58 @@ static PyObject * | |||
| _io__RawIOBase_read_impl(PyObject *self, Py_ssize_t n) | |||
| /*[clinic end generated code: output=6cdeb731e3c9f13c input=b6d0dcf6417d1374]*/ | |||
| { | |||
| PyObject *b, *res; | |||
| PyObject *b, *res, *mem; | |||
| Py_ssize_t newn, refcnt; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These new variables don't need to be declared at the top of the block.
|
@tzickel Are you still working on this? |


https://bugs.python.org/issue35210