gh-109523: Raise a BlockingIOError if reading text from a non-blocking stream cannot immediately return bytes. (GH-122933)

This commit is contained in:
Giovanni Siragusa 2024-12-02 14:18:30 +01:00 committed by GitHub
parent 930ba0ce60
commit 31f16e427b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 57 additions and 1 deletions

View file

@ -1992,6 +1992,12 @@ _io_TextIOWrapper_read_impl(textio *self, Py_ssize_t n)
if (bytes == NULL)
goto fail;
if (bytes == Py_None){
Py_DECREF(bytes);
PyErr_SetString(PyExc_BlockingIOError, "Read returned None.");
return NULL;
}
_PyIO_State *state = self->state;
if (Py_IS_TYPE(self->decoder, state->PyIncrementalNewlineDecoder_Type))
decoded = _PyIncrementalNewlineDecoder_decode(self->decoder,