summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorOren Milman <orenmn@gmail.com>2017-08-25 18:14:54 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2017-08-25 18:14:54 (GMT)
commita5b4ea15b61e3f3985f4f0748a18f8b888a63532 (patch)
tree1fe8d1d522298d73105b17b9129e2a7c52ea2e00 /Modules
parentdce6502059f46a04f90938b9d832394c8215397b (diff)
downloadcpython-a5b4ea15b61e3f3985f4f0748a18f8b888a63532.zip
cpython-a5b4ea15b61e3f3985f4f0748a18f8b888a63532.tar.gz
cpython-a5b4ea15b61e3f3985f4f0748a18f8b888a63532.tar.bz2
bpo-31271: Fix an assertion failure in io.TextIOWrapper.write. (#3201)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_io/textio.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c
index 5103ae6..402f743 100644
--- a/Modules/_io/textio.c
+++ b/Modules/_io/textio.c
@@ -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);