Issue #28769: The result of PyUnicode_AsUTF8AndSize() and PyUnicode_AsUTF8()
is now of type "const char *" rather of "char *".
diff --git a/Doc/c-api/unicode.rst b/Doc/c-api/unicode.rst
index a5d6c86..bcae44e 100644
--- a/Doc/c-api/unicode.rst
+++ b/Doc/c-api/unicode.rst
@@ -1038,7 +1038,7 @@
    raised by the codec.
 
 
-.. c:function:: char* PyUnicode_AsUTF8AndSize(PyObject *unicode, Py_ssize_t *size)
+.. c:function:: const char* PyUnicode_AsUTF8AndSize(PyObject *unicode, Py_ssize_t *size)
 
    Return a pointer to the UTF-8 encoding of the Unicode object, and
    store the size of the encoded representation (in bytes) in *size*.  The
@@ -1055,13 +1055,19 @@
 
    .. versionadded:: 3.3
 
+   .. versionchanged:: 3.7
+      The return type is now ``const char *`` rather of ``char *``.
 
-.. c:function:: char* PyUnicode_AsUTF8(PyObject *unicode)
+
+.. c:function:: const char* PyUnicode_AsUTF8(PyObject *unicode)
 
    As :c:func:`PyUnicode_AsUTF8AndSize`, but does not store the size.
 
    .. versionadded:: 3.3
 
+   .. versionchanged:: 3.7
+      The return type is now ``const char *`` rather of ``char *``.
+
 
 .. c:function:: PyObject* PyUnicode_EncodeUTF8(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
 
diff --git a/Doc/whatsnew/3.7.rst b/Doc/whatsnew/3.7.rst
index fe03def..5353a14 100644
--- a/Doc/whatsnew/3.7.rst
+++ b/Doc/whatsnew/3.7.rst
@@ -124,6 +124,10 @@
   and :c:type:`wrapperbase` are now of type ``const char *`` rather of
   ``char *``.  (Contributed by Serhiy Storchaka in :issue:`28761`.)
 
+* The result of :c:func:`PyUnicode_AsUTF8AndSize` and :c:func:`PyUnicode_AsUTF8`
+  is now of type ``const char *`` rather of ``char *``.
+  (Contributed by Serhiy Storchaka in :issue:`28769`.)
+
 
 Deprecated
 ==========
diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h
index 87cd96d..6a0740a 100644
--- a/Include/unicodeobject.h
+++ b/Include/unicodeobject.h
@@ -1135,7 +1135,7 @@
 */
 
 #ifndef Py_LIMITED_API
-PyAPI_FUNC(char *) PyUnicode_AsUTF8AndSize(
+PyAPI_FUNC(const char *) PyUnicode_AsUTF8AndSize(
     PyObject *unicode,
     Py_ssize_t *size);
 #define _PyUnicode_AsStringAndSize PyUnicode_AsUTF8AndSize
@@ -1162,7 +1162,7 @@
 */
 
 #ifndef Py_LIMITED_API
-PyAPI_FUNC(char *) PyUnicode_AsUTF8(PyObject *unicode);
+PyAPI_FUNC(const char *) PyUnicode_AsUTF8(PyObject *unicode);
 #define _PyUnicode_AsString PyUnicode_AsUTF8
 #endif
 
diff --git a/Misc/NEWS b/Misc/NEWS
index efd8e32..c68ffe8 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -614,6 +614,9 @@
 C API
 -----
 
+- Issue #28769: The result of PyUnicode_AsUTF8AndSize() and PyUnicode_AsUTF8()
+  is now of type "const char *" rather of "char *".
+
 - Issue #29058: All stable API extensions added after Python 3.2 are now
   available only when Py_LIMITED_API is set to the PY_VERSION_HEX value of
   the minimum Python version supporting this API.
diff --git a/Modules/_dbmmodule.c b/Modules/_dbmmodule.c
index 804978a..52bdd0b 100644
--- a/Modules/_dbmmodule.c
+++ b/Modules/_dbmmodule.c
@@ -239,7 +239,7 @@
          return -1;
     }
     if (PyUnicode_Check(arg)) {
-        key.dptr = PyUnicode_AsUTF8AndSize(arg, &size);
+        key.dptr = (char *)PyUnicode_AsUTF8AndSize(arg, &size);
         key.dsize = size;
         if (key.dptr == NULL)
             return -1;
diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c
index fcc1f15..933b3f5 100644
--- a/Modules/_decimal/_decimal.c
+++ b/Modules/_decimal/_decimal.c
@@ -3199,7 +3199,7 @@
     }
 
     if (PyUnicode_Check(fmtarg)) {
-        fmt = PyUnicode_AsUTF8AndSize(fmtarg, &size);
+        fmt = (char *)PyUnicode_AsUTF8AndSize(fmtarg, &size);
         if (fmt == NULL) {
             return NULL;
         }
diff --git a/Modules/_gdbmmodule.c b/Modules/_gdbmmodule.c
index daae71d..b727ba6 100644
--- a/Modules/_gdbmmodule.c
+++ b/Modules/_gdbmmodule.c
@@ -319,7 +319,7 @@
         return -1;
     }
     if (PyUnicode_Check(arg)) {
-        key.dptr = PyUnicode_AsUTF8AndSize(arg, &size);
+        key.dptr = (char *)PyUnicode_AsUTF8AndSize(arg, &size);
         key.dsize = size;
         if (key.dptr == NULL)
             return -1;
diff --git a/Objects/object.c b/Objects/object.c
index 7b80bcb..93cdc10 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -890,10 +890,10 @@
     if (tp->tp_getattro != NULL)
         return (*tp->tp_getattro)(v, name);
     if (tp->tp_getattr != NULL) {
-        char *name_str = PyUnicode_AsUTF8(name);
+        const char *name_str = PyUnicode_AsUTF8(name);
         if (name_str == NULL)
             return NULL;
-        return (*tp->tp_getattr)(v, name_str);
+        return (*tp->tp_getattr)(v, (char *)name_str);
     }
     PyErr_Format(PyExc_AttributeError,
                  "'%.50s' object has no attribute '%U'",
@@ -934,10 +934,10 @@
         return err;
     }
     if (tp->tp_setattr != NULL) {
-        char *name_str = PyUnicode_AsUTF8(name);
+        const char *name_str = PyUnicode_AsUTF8(name);
         if (name_str == NULL)
             return -1;
-        err = (*tp->tp_setattr)(v, name_str, value);
+        err = (*tp->tp_setattr)(v, (char *)name_str, value);
         Py_DECREF(name);
         return err;
     }
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 5fbe56c..b711f0c 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -3972,7 +3972,7 @@
 }
 
 
-char*
+const char *
 PyUnicode_AsUTF8AndSize(PyObject *unicode, Py_ssize_t *psize)
 {
     PyObject *bytes;
@@ -4007,7 +4007,7 @@
     return PyUnicode_UTF8(unicode);
 }
 
-char*
+const char *
 PyUnicode_AsUTF8(PyObject *unicode)
 {
     return PyUnicode_AsUTF8AndSize(unicode, NULL);