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

(cherry picked from commit 23db935bcf258657682e66464bf8512def8af830)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c
index 717b56a..fa162e2 100644
--- a/Modules/_io/textio.c
+++ b/Modules/_io/textio.c
@@ -694,6 +694,9 @@
     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 @@
         Py_DECREF(ret);
     }
 
+    textiowrapper_set_decoded_chars(self, NULL);
     Py_CLEAR(self->snapshot);
 
     if (self->decoder) {
@@ -1835,6 +1839,7 @@
         if (result == NULL)
             goto fail;
 
+        textiowrapper_set_decoded_chars(self, NULL);
         Py_CLEAR(self->snapshot);
         return result;
     }