bpo-25862: Fix assertion failures in io.TextIOWrapper.tell(). (GH-3918)

This commit is contained in:
Zackery Spytz 2018-06-29 04:14:58 -06:00 committed by Serhiy Storchaka
parent bda9c3eae3
commit 23db935bcf
4 changed files with 19 additions and 0 deletions

View file

@ -694,6 +694,9 @@ typedef struct
PyObject *dict;
} textio;
static void
textiowrapper_set_decoded_chars(textio *self, PyObject *chars);
/* A couple of specialized cases in order to bypass the slow incremental
encoding methods for the most popular encodings. */
@ -1606,6 +1609,7 @@ _io_TextIOWrapper_write_impl(textio *self, PyObject *text)
Py_DECREF(ret);
}
textiowrapper_set_decoded_chars(self, NULL);
Py_CLEAR(self->snapshot);
if (self->decoder) {
@ -1835,6 +1839,7 @@ _io_TextIOWrapper_read_impl(textio *self, Py_ssize_t n)
if (result == NULL)
goto fail;
textiowrapper_set_decoded_chars(self, NULL);
Py_CLEAR(self->snapshot);
return result;
}