Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-80527: Deprecate PEP 623 Unicode functions #91801

Merged
merged 2 commits into from
Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions Include/cpython/unicodeobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ static inline Py_ssize_t PyUnicode_WSTR_LENGTH(PyObject *op)
If the Py_UNICODE representation is not available, it will be computed
on request. Use PyUnicode_GET_LENGTH() for the length in code points. */

/* Py_DEPRECATED(3.3) */
Py_DEPRECATED(3.3)
static inline Py_ssize_t PyUnicode_GET_SIZE(PyObject *op)
{
_Py_COMP_DIAG_PUSH
Expand All @@ -620,10 +620,13 @@ static inline Py_ssize_t PyUnicode_GET_SIZE(PyObject *op)
}
#define PyUnicode_GET_SIZE(op) PyUnicode_GET_SIZE(_PyObject_CAST(op))

/* Py_DEPRECATED(3.3) */
static inline Py_ssize_t PyUnicode_GET_DATA_SIZE(PyObject *op)
Py_DEPRECATED(3.3)
static inline Py_ssize_t PyUnicode_GET_DATA_SIZE(PyObject *op)
{
_Py_COMP_DIAG_PUSH
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
return PyUnicode_GET_SIZE(op) * Py_UNICODE_SIZE;
_Py_COMP_DIAG_POP
}
#define PyUnicode_GET_DATA_SIZE(op) PyUnicode_GET_DATA_SIZE(_PyObject_CAST(op))

Expand All @@ -632,7 +635,7 @@ static inline Py_ssize_t PyUnicode_GET_SIZE(PyObject *op)
try to port your code to use the new PyUnicode_*BYTE_DATA() macros or
use PyUnicode_WRITE() and PyUnicode_READ(). */

/* Py_DEPRECATED(3.3) */
Py_DEPRECATED(3.3)
static inline Py_UNICODE* PyUnicode_AS_UNICODE(PyObject *op)
{
wchar_t *wstr = _PyASCIIObject_CAST(op)->wstr;
Expand All @@ -647,10 +650,13 @@ static inline Py_UNICODE* PyUnicode_AS_UNICODE(PyObject *op)
}
#define PyUnicode_AS_UNICODE(op) PyUnicode_AS_UNICODE(_PyObject_CAST(op))

/* Py_DEPRECATED(3.3) */
Py_DEPRECATED(3.3)
static inline const char* PyUnicode_AS_DATA(PyObject *op)
{
_Py_COMP_DIAG_PUSH
_Py_COMP_DIAG_IGNORE_DEPR_DECLS
return (const char *)PyUnicode_AS_UNICODE(op);
_Py_COMP_DIAG_POP
}
#define PyUnicode_AS_DATA(op) PyUnicode_AS_DATA(_PyObject_CAST(op))

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Mark functions as deprecated by :pep:`623`: :c:func:`PyUnicode_AS_DATA`,
:c:func:`PyUnicode_AS_UNICODE`, :c:func:`PyUnicode_GET_DATA_SIZE`,
:c:func:`PyUnicode_GET_SIZE`. Patch by Victor Stinner.