mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
bpo-31271: Fix an assertion failure in io.TextIOWrapper.write. (#3201)
This commit is contained in:
parent
dce6502059
commit
a5b4ea15b6
3 changed files with 17 additions and 0 deletions
|
|
@ -1387,6 +1387,13 @@ _io_TextIOWrapper_write_impl(textio *self, PyObject *text)
|
|||
Py_DECREF(text);
|
||||
if (b == NULL)
|
||||
return NULL;
|
||||
if (!PyBytes_Check(b)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"encoder should return a bytes object, not '%.200s'",
|
||||
Py_TYPE(b)->tp_name);
|
||||
Py_DECREF(b);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (self->pending_bytes == NULL) {
|
||||
self->pending_bytes = PyList_New(0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue