mirror of
https://github.com/python/cpython.git
synced 2025-10-09 08:31:26 +00:00
bpo-41123: Remove PyUnicode_AsUnicodeCopy (GH-21209)
This commit is contained in:
parent
2515a28230
commit
b3332660ad
6 changed files with 5 additions and 58 deletions
|
@ -724,20 +724,6 @@ Extension modules can continue using them, as they will not be removed in Python
|
||||||
.. versionadded:: 3.3
|
.. versionadded:: 3.3
|
||||||
|
|
||||||
|
|
||||||
.. c:function:: Py_UNICODE* PyUnicode_AsUnicodeCopy(PyObject *unicode)
|
|
||||||
|
|
||||||
Create a copy of a Unicode string ending with a null code point. Return ``NULL``
|
|
||||||
and raise a :exc:`MemoryError` exception on memory allocation failure,
|
|
||||||
otherwise return a new allocated buffer (use :c:func:`PyMem_Free` to free
|
|
||||||
the buffer). Note that the resulting :c:type:`Py_UNICODE*` string may
|
|
||||||
contain embedded null code points, which would cause the string to be
|
|
||||||
truncated when used in most C functions.
|
|
||||||
|
|
||||||
.. versionadded:: 3.2
|
|
||||||
|
|
||||||
Please migrate to using :c:func:`PyUnicode_AsUCS4Copy` or similar new APIs.
|
|
||||||
|
|
||||||
|
|
||||||
.. c:function:: Py_ssize_t PyUnicode_GetSize(PyObject *unicode)
|
.. c:function:: Py_ssize_t PyUnicode_GetSize(PyObject *unicode)
|
||||||
|
|
||||||
Return the size of the deprecated :c:type:`Py_UNICODE` representation, in
|
Return the size of the deprecated :c:type:`Py_UNICODE` representation, in
|
||||||
|
|
|
@ -2419,9 +2419,6 @@ PyUnicode_AsUnicodeAndSize:Py_UNICODE*:::
|
||||||
PyUnicode_AsUnicodeAndSize:PyObject*:unicode:0:
|
PyUnicode_AsUnicodeAndSize:PyObject*:unicode:0:
|
||||||
PyUnicode_AsUnicodeAndSize:Py_ssize_t*:size::
|
PyUnicode_AsUnicodeAndSize:Py_ssize_t*:size::
|
||||||
|
|
||||||
PyUnicode_AsUnicodeCopy:Py_UNICODE*:::
|
|
||||||
PyUnicode_AsUnicodeCopy:PyObject*:unicode:0:
|
|
||||||
|
|
||||||
PyUnicode_GetSize:Py_ssize_t:::
|
PyUnicode_GetSize:Py_ssize_t:::
|
||||||
PyUnicode_GetSize:PyObject*:unicode:0:
|
PyUnicode_GetSize:PyObject*:unicode:0:
|
||||||
|
|
||||||
|
|
|
@ -240,3 +240,7 @@ Removed
|
||||||
|
|
||||||
* Removed ``PyLong_FromUnicode()``. Please migrate to :c:func:`PyLong_FromUnicodeObject`.
|
* Removed ``PyLong_FromUnicode()``. Please migrate to :c:func:`PyLong_FromUnicodeObject`.
|
||||||
(Contributed by Inada Naoki in :issue:`41103`.)
|
(Contributed by Inada Naoki in :issue:`41103`.)
|
||||||
|
|
||||||
|
* Removed ``PyUnicode_AsUnicodeCopy()``. Please use :c:func:`PyUnicode_AsUCS4Copy` or
|
||||||
|
:c:func:`PyUnicode_AsWideCharString`
|
||||||
|
(Contributed by Inada Naoki in :issue:`41103`.)
|
||||||
|
|
|
@ -1162,14 +1162,6 @@ PyAPI_FUNC(int) _PyUnicode_IsAlpha(
|
||||||
|
|
||||||
PyAPI_FUNC(PyObject*) _PyUnicode_FormatLong(PyObject *, int, int, int);
|
PyAPI_FUNC(PyObject*) _PyUnicode_FormatLong(PyObject *, int, int, int);
|
||||||
|
|
||||||
/* Create a copy of a unicode string ending with a nul character. Return NULL
|
|
||||||
and raise a MemoryError exception on memory allocation failure, otherwise
|
|
||||||
return a new allocated buffer (use PyMem_Free() to free the buffer). */
|
|
||||||
|
|
||||||
Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE*) PyUnicode_AsUnicodeCopy(
|
|
||||||
PyObject *unicode
|
|
||||||
);
|
|
||||||
|
|
||||||
/* Return an interned Unicode object for an Identifier; may fail if there is no memory.*/
|
/* Return an interned Unicode object for an Identifier; may fail if there is no memory.*/
|
||||||
PyAPI_FUNC(PyObject*) _PyUnicode_FromId(_Py_Identifier*);
|
PyAPI_FUNC(PyObject*) _PyUnicode_FromId(_Py_Identifier*);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Remove ``PyUnicode_AsUnicodeCopy``.
|
|
@ -15862,39 +15862,6 @@ unicode_iter(PyObject *seq)
|
||||||
return (PyObject *)it;
|
return (PyObject *)it;
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_UNICODE*
|
|
||||||
PyUnicode_AsUnicodeCopy(PyObject *unicode)
|
|
||||||
{
|
|
||||||
Py_UNICODE *u, *copy;
|
|
||||||
Py_ssize_t len, size;
|
|
||||||
|
|
||||||
if (!PyUnicode_Check(unicode)) {
|
|
||||||
PyErr_BadArgument();
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
_Py_COMP_DIAG_PUSH
|
|
||||||
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
|
|
||||||
u = PyUnicode_AsUnicodeAndSize(unicode, &len);
|
|
||||||
_Py_COMP_DIAG_POP
|
|
||||||
if (u == NULL)
|
|
||||||
return NULL;
|
|
||||||
/* Ensure we won't overflow the size. */
|
|
||||||
if (len > ((PY_SSIZE_T_MAX / (Py_ssize_t)sizeof(Py_UNICODE)) - 1)) {
|
|
||||||
PyErr_NoMemory();
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
size = len + 1; /* copy the null character */
|
|
||||||
size *= sizeof(Py_UNICODE);
|
|
||||||
copy = PyMem_Malloc(size);
|
|
||||||
if (copy == NULL) {
|
|
||||||
PyErr_NoMemory();
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
memcpy(copy, u, size);
|
|
||||||
return copy;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
encode_wstr_utf8(wchar_t *wstr, char **str, const char *name)
|
encode_wstr_utf8(wchar_t *wstr, char **str, const char *name)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue