Uh oh!
There was an error while loading. Please reload this page.
io: improve bytes handling - #9059
Conversation
This comment has been minimized.
This comment has been minimized.
It isn't that easy, unfortunately: This is the implemenation: https://github.com/python/cpython/blob/934b25dcc492dcbca4da9d63d0d71dc940fc0375/Modules/_io/textio.c#L284 PyObject*_PyIncrementalNewlineDecoder_decode(PyObject*myself,
PyObject*input, intfinal)
{
PyObject*output;
Py_ssize_toutput_len;
nldecoder_object*self= (nldecoder_object*) myself;
if (self->decoder==NULL) {
PyErr_SetString(PyExc_ValueError,
"IncrementalNewlineDecoder.__init__ not called");
returnNULL;
}
/* decode input (with the eventual \r from a previous pass) */if (self->decoder!=Py_None) {
output=PyObject_CallMethodObjArgs(self->decoder,
&_Py_ID(decode), input, final ? Py_True : Py_False, NULL);
}
else {
output=input;
Py_INCREF(output);
}
if (check_decoded(output) <0)
returnNULL;
/* ... */So, there are code paths, where only |
sobolevn
commented
Nov 1, 2022
Ok, let's go with an easy solution. I don't have any other ideas :( |
This comment has been minimized.
This comment has been minimized.
JelleZijlstra
commented
Nov 2, 2022
I'm not sure this is quite right either. The argument gets passed to |
sobolevn
commented
Nov 2, 2022
Yes, you are correct. Here's the full sequence:
Then So, I will create a new PR to fix |
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
sobolevn
commented
Nov 2, 2022
There's an unrelated failure in the CI. |
IncrementalNewlineDecoder.decodedoes not supportstr, but supportsbytearrayandmemoryview:Buffers: