Skip to content

Commit 20a7902

Browse files
authored
bpo-41123: Remove Py_UNICODE_str* functions (GH-21164)
They are undocumented and deprecated since Python 3.3.
1 parent 2f168c6 commit 20a7902

File tree

4 files changed

+16
-126
lines changed

4 files changed

+16
-126
lines changed

Doc/whatsnew/3.10.rst

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,4 +208,18 @@ Removed
208208
* ``PyObject_AsCharBuffer()``, ``PyObject_AsReadBuffer()``, ``PyObject_CheckReadBuffer()``,
209209
and ``PyObject_AsWriteBuffer()`` are removed. Please migrate to new buffer protocol;
210210
:c:func:`PyObject_GetBuffer` and :c:func:`PyBuffer_Release`.
211-
(Contributed by Inada Naoki in :issue:`41103`.
211+
(Contributed by Inada Naoki in :issue:`41103`.)
212+
213+
* Removed ``Py_UNICODE_str*`` functions manipulating ``Py_UNICODE*`` strings.
214+
(Contributed by Inada Naoki in :issue:`41123`.)
215+
216+
* ``Py_UNICODE_strlen``: use :c:func:`PyUnicode_GetLength` or
217+
:c:macro:`PyUnicode_GET_LENGTH`
218+
* ``Py_UNICODE_strcat``: use :c:func:`PyUnicode_CopyCharacters` or
219+
:c:func:`PyUnicode_FromFormat`
220+
* ``Py_UNICODE_strcpy``, ``Py_UNICODE_strncpy``: use
221+
:c:func:`PyUnicode_CopyCharacters` or :c:func:`PyUnicode_Substring`
222+
* ``Py_UNICODE_strcmp``: use :c:func:`PyUnicode_Compare`
223+
* ``Py_UNICODE_strncmp``: use :c:func:`PyUnicode_Tailmatch`
224+
* ``Py_UNICODE_strchr``, ``Py_UNICODE_strrchr``: use
225+
:c:func:`PyUnicode_FindChar`

Include/cpython/unicodeobject.h

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,43 +1163,6 @@ PyAPI_FUNC(int) _PyUnicode_IsAlpha(
11631163
Py_UCS4 ch /* Unicode character */
11641164
);
11651165

1166-
Py_DEPRECATED(3.3) PyAPI_FUNC(size_t) Py_UNICODE_strlen(
1167-
const Py_UNICODE *u
1168-
);
1169-
1170-
Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strcpy(
1171-
Py_UNICODE *s1,
1172-
const Py_UNICODE *s2);
1173-
1174-
Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strcat(
1175-
Py_UNICODE *s1, const Py_UNICODE *s2);
1176-
1177-
Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strncpy(
1178-
Py_UNICODE *s1,
1179-
const Py_UNICODE *s2,
1180-
size_t n);
1181-
1182-
Py_DEPRECATED(3.3) PyAPI_FUNC(int) Py_UNICODE_strcmp(
1183-
const Py_UNICODE *s1,
1184-
const Py_UNICODE *s2
1185-
);
1186-
1187-
Py_DEPRECATED(3.3) PyAPI_FUNC(int) Py_UNICODE_strncmp(
1188-
const Py_UNICODE *s1,
1189-
const Py_UNICODE *s2,
1190-
size_t n
1191-
);
1192-
1193-
Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strchr(
1194-
const Py_UNICODE *s,
1195-
Py_UNICODE c
1196-
);
1197-
1198-
Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strrchr(
1199-
const Py_UNICODE *s,
1200-
Py_UNICODE c
1201-
);
1202-
12031166
PyAPI_FUNC(PyObject*) _PyUnicode_FormatLong(PyObject *, int, int, int);
12041167

12051168
/* Create a copy of a unicode string ending with a nul character. Return NULL
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Removed ``Py_UNICODE_str*`` functions manipulating ``Py_UNICODE*`` strings.

Objects/unicodeobject.c

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -15888,94 +15888,6 @@ unicode_iter(PyObject *seq)
1588815888
return (PyObject *)it;
1588915889
}
1589015890

15891-
15892-
size_t
15893-
Py_UNICODE_strlen(const Py_UNICODE *u)
15894-
{
15895-
return wcslen(u);
15896-
}
15897-
15898-
Py_UNICODE*
15899-
Py_UNICODE_strcpy(Py_UNICODE *s1, const Py_UNICODE *s2)
15900-
{
15901-
Py_UNICODE *u = s1;
15902-
while ((*u++ = *s2++));
15903-
return s1;
15904-
}
15905-
15906-
Py_UNICODE*
15907-
Py_UNICODE_strncpy(Py_UNICODE *s1, const Py_UNICODE *s2, size_t n)
15908-
{
15909-
Py_UNICODE *u = s1;
15910-
while ((*u++ = *s2++))
15911-
if (n-- == 0)
15912-
break;
15913-
return s1;
15914-
}
15915-
15916-
Py_UNICODE*
15917-
Py_UNICODE_strcat(Py_UNICODE *s1, const Py_UNICODE *s2)
15918-
{
15919-
Py_UNICODE *u1 = s1;
15920-
u1 += wcslen(u1);
15921-
while ((*u1++ = *s2++));
15922-
return s1;
15923-
}
15924-
15925-
int
15926-
Py_UNICODE_strcmp(const Py_UNICODE *s1, const Py_UNICODE *s2)
15927-
{
15928-
while (*s1 && *s2 && *s1 == *s2)
15929-
s1++, s2++;
15930-
if (*s1 && *s2)
15931-
return (*s1 < *s2) ? -1 : +1;
15932-
if (*s1)
15933-
return 1;
15934-
if (*s2)
15935-
return -1;
15936-
return 0;
15937-
}
15938-
15939-
int
15940-
Py_UNICODE_strncmp(const Py_UNICODE *s1, const Py_UNICODE *s2, size_t n)
15941-
{
15942-
Py_UNICODE u1, u2;
15943-
for (; n != 0; n--) {
15944-
u1 = *s1;
15945-
u2 = *s2;
15946-
if (u1 != u2)
15947-
return (u1 < u2) ? -1 : +1;
15948-
if (u1 == '\0')
15949-
return 0;
15950-
s1++;
15951-
s2++;
15952-
}
15953-
return 0;
15954-
}
15955-
15956-
Py_UNICODE*
15957-
Py_UNICODE_strchr(const Py_UNICODE *s, Py_UNICODE c)
15958-
{
15959-
const Py_UNICODE *p;
15960-
for (p = s; *p; p++)
15961-
if (*p == c)
15962-
return (Py_UNICODE*)p;
15963-
return NULL;
15964-
}
15965-
15966-
Py_UNICODE*
15967-
Py_UNICODE_strrchr(const Py_UNICODE *s, Py_UNICODE c)
15968-
{
15969-
const Py_UNICODE *p;
15970-
p = s + wcslen(s);
15971-
while (p != s) {
15972-
p--;
15973-
if (*p == c)
15974-
return (Py_UNICODE*)p;
15975-
}
15976-
return NULL;
15977-
}
15978-
1597915891
Py_UNICODE*
1598015892
PyUnicode_AsUnicodeCopy(PyObject *unicode)
1598115893
{

0 commit comments

Comments
 (0)