[Python-checkins] bpo-41123: Remove Py_UNICODE_str* functions (GH-21164)

Inada Naoki webhook-mailer at python.org
Sat Jun 27 05:22:13 EDT 2020


https://github.com/python/cpython/commit/20a79021753ab26a5989e6d3397160e52973870e
commit: 20a79021753ab26a5989e6d3397160e52973870e
branch: master
author: Inada Naoki <songofacandy at gmail.com>
committer: GitHub <noreply at github.com>
date: 2020-06-27T18:22:09+09:00
summary:

bpo-41123: Remove Py_UNICODE_str* functions (GH-21164)

They are undocumented and deprecated since Python 3.3.

files:
A Misc/NEWS.d/next/C API/2020-06-26-13-29-25.bpo-41123.bRa1oy.rst
M Doc/whatsnew/3.10.rst
M Include/cpython/unicodeobject.h
M Objects/unicodeobject.c

diff --git a/Doc/whatsnew/3.10.rst b/Doc/whatsnew/3.10.rst
index 060d5debf91a9..51e42ec6aba91 100644
--- a/Doc/whatsnew/3.10.rst
+++ b/Doc/whatsnew/3.10.rst
@@ -208,4 +208,18 @@ Removed
 * ``PyObject_AsCharBuffer()``, ``PyObject_AsReadBuffer()``, ``PyObject_CheckReadBuffer()``,
   and ``PyObject_AsWriteBuffer()`` are removed. Please migrate to new buffer protocol;
   :c:func:`PyObject_GetBuffer` and :c:func:`PyBuffer_Release`.
-  (Contributed by Inada Naoki in :issue:`41103`.
+  (Contributed by Inada Naoki in :issue:`41103`.)
+
+* Removed ``Py_UNICODE_str*`` functions manipulating ``Py_UNICODE*`` strings.
+  (Contributed by Inada Naoki in :issue:`41123`.)
+
+   * ``Py_UNICODE_strlen``: use :c:func:`PyUnicode_GetLength` or
+     :c:macro:`PyUnicode_GET_LENGTH`
+   * ``Py_UNICODE_strcat``: use :c:func:`PyUnicode_CopyCharacters` or
+     :c:func:`PyUnicode_FromFormat`
+   * ``Py_UNICODE_strcpy``, ``Py_UNICODE_strncpy``: use
+     :c:func:`PyUnicode_CopyCharacters` or :c:func:`PyUnicode_Substring`
+   * ``Py_UNICODE_strcmp``: use :c:func:`PyUnicode_Compare`
+   * ``Py_UNICODE_strncmp``: use :c:func:`PyUnicode_Tailmatch`
+   * ``Py_UNICODE_strchr``, ``Py_UNICODE_strrchr``: use
+     :c:func:`PyUnicode_FindChar`
diff --git a/Include/cpython/unicodeobject.h b/Include/cpython/unicodeobject.h
index 7e53ccc9e63f0..bcf99849f9f66 100644
--- a/Include/cpython/unicodeobject.h
+++ b/Include/cpython/unicodeobject.h
@@ -1163,43 +1163,6 @@ PyAPI_FUNC(int) _PyUnicode_IsAlpha(
     Py_UCS4 ch       /* Unicode character */
     );
 
-Py_DEPRECATED(3.3) PyAPI_FUNC(size_t) Py_UNICODE_strlen(
-    const Py_UNICODE *u
-    );
-
-Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strcpy(
-    Py_UNICODE *s1,
-    const Py_UNICODE *s2);
-
-Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strcat(
-    Py_UNICODE *s1, const Py_UNICODE *s2);
-
-Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strncpy(
-    Py_UNICODE *s1,
-    const Py_UNICODE *s2,
-    size_t n);
-
-Py_DEPRECATED(3.3) PyAPI_FUNC(int) Py_UNICODE_strcmp(
-    const Py_UNICODE *s1,
-    const Py_UNICODE *s2
-    );
-
-Py_DEPRECATED(3.3) PyAPI_FUNC(int) Py_UNICODE_strncmp(
-    const Py_UNICODE *s1,
-    const Py_UNICODE *s2,
-    size_t n
-    );
-
-Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strchr(
-    const Py_UNICODE *s,
-    Py_UNICODE c
-    );
-
-Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strrchr(
-    const Py_UNICODE *s,
-    Py_UNICODE c
-    );
-
 PyAPI_FUNC(PyObject*) _PyUnicode_FormatLong(PyObject *, int, int, int);
 
 /* Create a copy of a unicode string ending with a nul character. Return NULL
diff --git a/Misc/NEWS.d/next/C API/2020-06-26-13-29-25.bpo-41123.bRa1oy.rst b/Misc/NEWS.d/next/C API/2020-06-26-13-29-25.bpo-41123.bRa1oy.rst
new file mode 100644
index 0000000000000..1261a8708d6c9
--- /dev/null
+++ b/Misc/NEWS.d/next/C API/2020-06-26-13-29-25.bpo-41123.bRa1oy.rst	
@@ -0,0 +1 @@
+Removed ``Py_UNICODE_str*`` functions manipulating ``Py_UNICODE*`` strings.
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 55c886727ba2e..dc0f525c3bfdc 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -15888,94 +15888,6 @@ unicode_iter(PyObject *seq)
     return (PyObject *)it;
 }
 
-
-size_t
-Py_UNICODE_strlen(const Py_UNICODE *u)
-{
-    return wcslen(u);
-}
-
-Py_UNICODE*
-Py_UNICODE_strcpy(Py_UNICODE *s1, const Py_UNICODE *s2)
-{
-    Py_UNICODE *u = s1;
-    while ((*u++ = *s2++));
-    return s1;
-}
-
-Py_UNICODE*
-Py_UNICODE_strncpy(Py_UNICODE *s1, const Py_UNICODE *s2, size_t n)
-{
-    Py_UNICODE *u = s1;
-    while ((*u++ = *s2++))
-        if (n-- == 0)
-            break;
-    return s1;
-}
-
-Py_UNICODE*
-Py_UNICODE_strcat(Py_UNICODE *s1, const Py_UNICODE *s2)
-{
-    Py_UNICODE *u1 = s1;
-    u1 += wcslen(u1);
-    while ((*u1++ = *s2++));
-    return s1;
-}
-
-int
-Py_UNICODE_strcmp(const Py_UNICODE *s1, const Py_UNICODE *s2)
-{
-    while (*s1 && *s2 && *s1 == *s2)
-        s1++, s2++;
-    if (*s1 && *s2)
-        return (*s1 < *s2) ? -1 : +1;
-    if (*s1)
-        return 1;
-    if (*s2)
-        return -1;
-    return 0;
-}
-
-int
-Py_UNICODE_strncmp(const Py_UNICODE *s1, const Py_UNICODE *s2, size_t n)
-{
-    Py_UNICODE u1, u2;
-    for (; n != 0; n--) {
-        u1 = *s1;
-        u2 = *s2;
-        if (u1 != u2)
-            return (u1 < u2) ? -1 : +1;
-        if (u1 == '\0')
-            return 0;
-        s1++;
-        s2++;
-    }
-    return 0;
-}
-
-Py_UNICODE*
-Py_UNICODE_strchr(const Py_UNICODE *s, Py_UNICODE c)
-{
-    const Py_UNICODE *p;
-    for (p = s; *p; p++)
-        if (*p == c)
-            return (Py_UNICODE*)p;
-    return NULL;
-}
-
-Py_UNICODE*
-Py_UNICODE_strrchr(const Py_UNICODE *s, Py_UNICODE c)
-{
-    const Py_UNICODE *p;
-    p = s + wcslen(s);
-    while (p != s) {
-        p--;
-        if (*p == c)
-            return (Py_UNICODE*)p;
-    }
-    return NULL;
-}
-
 Py_UNICODE*
 PyUnicode_AsUnicodeCopy(PyObject *unicode)
 {



More information about the Python-checkins mailing list