[2.7] bpo-25359: Add missed "goto error" after setting an exception. (GH-3712) (#3779)

(cherry picked from commit d6238a76c655e0feb13478505220dc9049f1682f)
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c
index d9e036d..bf37f72 100644
--- a/Modules/_io/textio.c
+++ b/Modules/_io/textio.c
@@ -907,6 +907,7 @@
     else {
         PyErr_SetString(PyExc_IOError,
                         "could not determine default encoding");
+        goto error;
     }
 
     /* Check we have been asked for a real text encoding */