Replaced outdated macros _PyUnicode_AsString and _PyUnicode_AsStringAndSize
with PyUnicode_AsUTF8 and PyUnicode_AsUTF8AndSize.
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 65c950e..4807e4f 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -1723,7 +1723,7 @@
     if (stgd && CDataObject_Check(value) && stgd->proto && PyUnicode_Check(stgd->proto)) {
         PyCArgObject *parg;
 
-        switch (_PyUnicode_AsString(stgd->proto)[0]) {
+        switch (PyUnicode_AsUTF8(stgd->proto)[0]) {
         case 'z': /* c_char_p */
         case 'Z': /* c_wchar_p */
             parg = PyCArgObject_new();
@@ -1835,7 +1835,7 @@
 
     dict = PyObject_stgdict((PyObject *)self);
     assert(dict); /* Cannot be NULL for CDataObject instances */
-    fmt = _PyUnicode_AsString(dict->proto);
+    fmt = PyUnicode_AsUTF8(dict->proto);
     assert(fmt);
 
     fd = _ctypes_get_fielddesc(fmt);
@@ -2059,7 +2059,7 @@
     assert(dict);
 
     /* I think we can rely on this being a one-character string */
-    fmt = _PyUnicode_AsString(dict->proto);
+    fmt = PyUnicode_AsUTF8(dict->proto);
     assert(fmt);
 
     fd = _ctypes_get_fielddesc(fmt);
@@ -3128,7 +3128,7 @@
         /* simple pointer types, c_void_p, c_wchar_p, BSTR, ... */
         && PyUnicode_Check(dict->proto)
 /* We only allow c_void_p, c_char_p and c_wchar_p as a simple output parameter type */
-        && (strchr("PzZ", _PyUnicode_AsString(dict->proto)[0]))) {
+        && (strchr("PzZ", PyUnicode_AsUTF8(dict->proto)[0]))) {
         return 1;
     }
 
@@ -3218,7 +3218,7 @@
         return *pname ? 1 : 0;
     }
     if (PyUnicode_Check(obj)) {
-        *pname = _PyUnicode_AsString(obj);
+        *pname = PyUnicode_AsUTF8(obj);
         return *pname ? 1 : 0;
     }
     PyErr_SetString(PyExc_TypeError,
@@ -5233,7 +5233,7 @@
     dict = PyType_stgdict(arg);
     if (dict) {
         if (PyUnicode_Check(dict->proto)
-            && (strchr("sPzUZXO", _PyUnicode_AsString(dict->proto)[0]))) {
+            && (strchr("sPzUZXO", PyUnicode_AsUTF8(dict->proto)[0]))) {
             /* simple pointer types, c_void_p, c_wchar_p, BSTR, ... */
             return 1;
         }
diff --git a/Modules/_ctypes/stgdict.c b/Modules/_ctypes/stgdict.c
index 6c0fda9..716d1e9 100644
--- a/Modules/_ctypes/stgdict.c
+++ b/Modules/_ctypes/stgdict.c
@@ -489,7 +489,7 @@
 
         if (isStruct && !isPacked) {
             char *fieldfmt = dict->format ? dict->format : "B";
-            char *fieldname = _PyUnicode_AsString(name);
+            char *fieldname = PyUnicode_AsUTF8(name);
             char *ptr;
             Py_ssize_t len;
             char *buf;
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
index 5ddf650..d0ddcc2 100644
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -1219,7 +1219,7 @@
     assert(object && format && timetuple);
     assert(PyUnicode_Check(format));
     /* Convert the input format to a C string and size */
-    pin = _PyUnicode_AsStringAndSize(format, &flen);
+    pin = PyUnicode_AsUTF8AndSize(format, &flen);
     if (!pin)
         return NULL;
 
@@ -1287,7 +1287,7 @@
             }
             assert(Zreplacement != NULL);
             assert(PyUnicode_Check(Zreplacement));
-            ptoappend = _PyUnicode_AsStringAndSize(Zreplacement,
+            ptoappend = PyUnicode_AsUTF8AndSize(Zreplacement,
                                                   &ntoappend);
             if (ptoappend == NULL)
                 goto Done;
diff --git a/Modules/_io/stringio.c b/Modules/_io/stringio.c
index ecf6dc1..8542efd 100644
--- a/Modules/_io/stringio.c
+++ b/Modules/_io/stringio.c
@@ -708,7 +708,7 @@
                          Py_TYPE(newline_obj)->tp_name);
             return -1;
         }
-        newline = _PyUnicode_AsString(newline_obj);
+        newline = PyUnicode_AsUTF8(newline_obj);
         if (newline == NULL)
             return -1;
     }
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c
index 2f55eb0..1c7200b 100644
--- a/Modules/_io/textio.c
+++ b/Modules/_io/textio.c
@@ -921,7 +921,7 @@
             Py_CLEAR(self->encoding);
     }
     if (self->encoding != NULL) {
-        encoding = _PyUnicode_AsString(self->encoding);
+        encoding = PyUnicode_AsUTF8(self->encoding);
         if (encoding == NULL)
             goto error;
     }
@@ -964,7 +964,7 @@
     }
     self->writetranslate = (newline == NULL || newline[0] != '\0');
     if (!self->readuniversal && self->readnl) {
-        self->writenl = _PyUnicode_AsString(self->readnl);
+        self->writenl = PyUnicode_AsUTF8(self->readnl);
         if (self->writenl == NULL)
             goto error;
         if (!strcmp(self->writenl, "\n"))
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index 54b1856..79113e0 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -1951,7 +1951,7 @@
         if (repr == NULL)
             goto error;
 
-        string = _PyUnicode_AsStringAndSize(repr, &size);
+        string = PyUnicode_AsUTF8AndSize(repr, &size);
         if (string == NULL)
             goto error;
 
diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c
index f37de42..1c6aa54 100644
--- a/Modules/_sqlite/connection.c
+++ b/Modules/_sqlite/connection.c
@@ -505,7 +505,7 @@
     } else if (PyFloat_Check(py_val)) {
         sqlite3_result_double(context, PyFloat_AsDouble(py_val));
     } else if (PyUnicode_Check(py_val)) {
-        const char *str = _PyUnicode_AsString(py_val);
+        const char *str = PyUnicode_AsUTF8(py_val);
         if (str == NULL)
             return -1;
         sqlite3_result_text(context, str, -1, SQLITE_TRANSIENT);
@@ -1527,7 +1527,7 @@
         }
     }
 
-    uppercase_name_str = _PyUnicode_AsString(uppercase_name);
+    uppercase_name_str = PyUnicode_AsUTF8(uppercase_name);
     if (!uppercase_name_str)
         goto finally;
 
diff --git a/Modules/_sqlite/cursor.c b/Modules/_sqlite/cursor.c
index c7169f6..39f7a65 100644
--- a/Modules/_sqlite/cursor.c
+++ b/Modules/_sqlite/cursor.c
@@ -465,7 +465,7 @@
         pysqlite_statement_reset(self->statement);
     }
 
-    operation_cstr = _PyUnicode_AsStringAndSize(operation, &operation_len);
+    operation_cstr = PyUnicode_AsUTF8AndSize(operation, &operation_len);
     if (operation_cstr == NULL)
         goto error;
 
@@ -689,7 +689,7 @@
     self->reset = 0;
 
     if (PyUnicode_Check(script_obj)) {
-        script_cstr = _PyUnicode_AsString(script_obj);
+        script_cstr = PyUnicode_AsUTF8(script_obj);
         if (!script_cstr) {
             return NULL;
         }
diff --git a/Modules/_sqlite/row.c b/Modules/_sqlite/row.c
index 07584e3..53342f3 100644
--- a/Modules/_sqlite/row.c
+++ b/Modules/_sqlite/row.c
@@ -98,7 +98,7 @@
         Py_XINCREF(item);
         return item;
     } else if (PyUnicode_Check(idx)) {
-        key = _PyUnicode_AsString(idx);
+        key = PyUnicode_AsUTF8(idx);
         if (key == NULL)
             return NULL;
 
@@ -108,7 +108,7 @@
             PyObject *obj;
             obj = PyTuple_GET_ITEM(self->description, i);
             obj = PyTuple_GET_ITEM(obj, 0);
-            compare_key = _PyUnicode_AsString(obj);
+            compare_key = PyUnicode_AsUTF8(obj);
             if (!compare_key) {
                 return NULL;
             }
diff --git a/Modules/_sqlite/statement.c b/Modules/_sqlite/statement.c
index 7b98013..0df661b 100644
--- a/Modules/_sqlite/statement.c
+++ b/Modules/_sqlite/statement.c
@@ -59,7 +59,7 @@
     self->st = NULL;
     self->in_use = 0;
 
-    sql_cstr = _PyUnicode_AsStringAndSize(sql, &sql_cstr_len);
+    sql_cstr = PyUnicode_AsUTF8AndSize(sql, &sql_cstr_len);
     if (sql_cstr == NULL) {
         rc = PYSQLITE_SQL_WRONG_TYPE;
         return rc;
@@ -152,7 +152,7 @@
             rc = sqlite3_bind_double(self->st, pos, PyFloat_AsDouble(parameter));
             break;
         case TYPE_UNICODE:
-            string = _PyUnicode_AsStringAndSize(parameter, &buflen);
+            string = PyUnicode_AsUTF8AndSize(parameter, &buflen);
             if (string == NULL)
                 return -1;
             if (buflen > INT_MAX) {
@@ -325,7 +325,7 @@
     Py_ssize_t sql_len;
     sqlite3_stmt* new_st;
 
-    sql_cstr = _PyUnicode_AsStringAndSize(self->sql, &sql_len);
+    sql_cstr = PyUnicode_AsUTF8AndSize(self->sql, &sql_len);
     if (sql_cstr == NULL) {
         rc = PYSQLITE_SQL_WRONG_TYPE;
         return rc;
diff --git a/Modules/cjkcodecs/cjkcodecs.h b/Modules/cjkcodecs/cjkcodecs.h
index b72a3f0..2ae28ec 100644
--- a/Modules/cjkcodecs/cjkcodecs.h
+++ b/Modules/cjkcodecs/cjkcodecs.h
@@ -267,7 +267,7 @@
                         "encoding name must be a string.");
         return NULL;
     }
-    enc = _PyUnicode_AsString(encoding);
+    enc = PyUnicode_AsUTF8(encoding);
     if (enc == NULL)
         return NULL;
 
diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c
index f5c8421..d1da189 100644
--- a/Modules/cjkcodecs/multibytecodec.c
+++ b/Modules/cjkcodecs/multibytecodec.c
@@ -85,7 +85,7 @@
     const char *str;
 
     assert(PyUnicode_Check(errors));
-    str = _PyUnicode_AsString(errors);
+    str = PyUnicode_AsUTF8(errors);
     if (str == NULL)
         return NULL;
     cb = PyCodec_LookupError(str);
@@ -138,7 +138,7 @@
         return -1;
     }
 
-    str = _PyUnicode_AsString(value);
+    str = PyUnicode_AsUTF8(value);
     if (str == NULL)
         return -1;
 
diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c
index 82770a5..b2566951 100644
--- a/Modules/parsermodule.c
+++ b/Modules/parsermodule.c
@@ -912,7 +912,7 @@
                     Py_DECREF(o);
                 }
             }
-            temp_str = _PyUnicode_AsStringAndSize(temp, &len);
+            temp_str = PyUnicode_AsUTF8AndSize(temp, &len);
             if (temp_str == NULL) {
                 Py_DECREF(temp);
                 Py_XDECREF(elem);
@@ -1013,7 +1013,7 @@
             if (res && encoding) {
                 Py_ssize_t len;
                 const char *temp;
-                temp = _PyUnicode_AsStringAndSize(encoding, &len);
+                temp = PyUnicode_AsUTF8AndSize(encoding, &len);
                 if (temp == NULL) {
                     Py_DECREF(res);
                     Py_DECREF(encoding);
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index acef3c3..ae25102 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -9325,7 +9325,7 @@
                 "configuration names must be strings or integers");
             return 0;
         }
-        confname = _PyUnicode_AsString(arg);
+        confname = PyUnicode_AsUTF8(arg);
         if (confname == NULL)
             return 0;
         while (lo < hi) {
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index c9a38cc..4c1d8f0 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -5989,7 +5989,7 @@
         PyOS_snprintf(pbuf, sizeof(pbuf), "%ld", value);
         pptr = pbuf;
     } else if (PyUnicode_Check(pobj)) {
-        pptr = _PyUnicode_AsString(pobj);
+        pptr = PyUnicode_AsUTF8(pobj);
         if (pptr == NULL)
             goto err;
     } else if (PyBytes_Check(pobj)) {
diff --git a/Modules/syslogmodule.c b/Modules/syslogmodule.c
index f2d44ff..7afca58 100644
--- a/Modules/syslogmodule.c
+++ b/Modules/syslogmodule.c
@@ -139,7 +139,7 @@
      * If NULL, just let openlog figure it out (probably using C argv[0]).
      */
     if (S_ident_o) {
-        ident = _PyUnicode_AsString(S_ident_o);
+        ident = PyUnicode_AsUTF8(S_ident_o);
         if (ident == NULL)
             return NULL;
     }
@@ -167,7 +167,7 @@
             return NULL;
     }
 
-    message = _PyUnicode_AsString(message_object);
+    message = PyUnicode_AsUTF8(message_object);
     if (message == NULL)
         return NULL;
 
diff --git a/Modules/timemodule.c b/Modules/timemodule.c
index f070833..db0ab58 100644
--- a/Modules/timemodule.c
+++ b/Modules/timemodule.c
@@ -441,7 +441,7 @@
     if (Py_TYPE(args) == &StructTimeType) {
         PyObject *item;
         item = PyTuple_GET_ITEM(args, 9);
-        p->tm_zone = item == Py_None ? NULL : _PyUnicode_AsString(item);
+        p->tm_zone = item == Py_None ? NULL : PyUnicode_AsUTF8(item);
         item = PyTuple_GET_ITEM(args, 10);
         p->tm_gmtoff = item == Py_None ? 0 : PyLong_AsLong(item);
         if (PyErr_Occurred())