8000 bpo-31271: fix an assertion failure in io.TextIOWrapper.write by orenmn · Pull Request #3201 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-31271: fix an assertion failure in io.TextIOWrapper.write #3201

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

Merged
merged 3 commits into from
Aug 25, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
8000
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
added a NEWS.d item, and made the error msg more like that of the sim…
…ilar error when the decoder doesn't return a str.
  • Loading branch information
orenmn committed Aug 25, 2017
commit 287275407ee485cad5f8041aa7ffc99ab8056c7c
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix an assertion failure in the write() method of `io.TextIOWrapper`, when
the encoder doesn't return a bytes object. Patch by Oren Milman.
3 changes: 1 addition & 2 deletions Modules/_io/textio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1381,8 +1381,7 @@ _io_TextIOWrapper_write_impl(textio *self, PyObject *text)
return NULL;
if (!PyBytes_Check(b)) {
PyErr_Format(PyExc_TypeError,
"encode() should have returned a bytes object, not "
"'%.200s'",
"encoder should return a bytes object, not '%.200s'",
Py_TYPE(b)->tp_name);
Py_DECREF(b);
return NULL;
Expand Down
0