diff options
author | Inada Naoki <songofacandy@gmail.com> | 2020-06-18 08:30:53 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-18 08:30:53 (GMT) |
commit | 610a60c601fb4380eee30e15be1cd4dcbdaeec4c (patch) | |
tree | c628710b4dc5552913a9b3cbe74b704e3b958d37 /Objects/unicodeobject.c | |
parent | 9a58f03dc21d15c076d051d902ce1d0324db9741 (diff) | |
download | cpython-610a60c601fb4380eee30e15be1cd4dcbdaeec4c.zip cpython-610a60c601fb4380eee30e15be1cd4dcbdaeec4c.tar.gz cpython-610a60c601fb4380eee30e15be1cd4dcbdaeec4c.tar.bz2 |
bpo-36346: Add Py_DEPRECATED to deprecated unicode APIs (GH-20878)
Co-authored-by: Kyle Stanley <aeros167@gmail.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
(cherry picked from commit 2c4928d37edc5e4aeec3c0b79fa3460b1ec9b60d)
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r-- | Objects/unicodeobject.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 1082eb4..4c8c880 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -120,6 +120,13 @@ extern "C" { _PyUnicode_UTF8_LENGTH(op)) #define _PyUnicode_WSTR(op) \ (((PyASCIIObject*)(op))->wstr) + +/* Don't use deprecated macro of unicodeobject.h */ +#undef PyUnicode_WSTR_LENGTH +#define PyUnicode_WSTR_LENGTH(op) \ + (PyUnicode_IS_COMPACT_ASCII(op) ? \ + ((PyASCIIObject*)op)->length : \ + ((PyCompactUnicodeObject*)op)->wstr_length) #define _PyUnicode_WSTR_LENGTH(op) \ (((PyCompactUnicodeObject*)(op))->wstr_length) #define _PyUnicode_LENGTH(op) \ @@ -964,11 +971,14 @@ ensure_unicode(PyObject *obj) #include "stringlib/find_max_char.h" #include "stringlib/undef.h" +_Py_COMP_DIAG_PUSH +_Py_COMP_DIAG_IGNORE_DEPR_DECLS #include "stringlib/unicodedefs.h" #include "stringlib/fastsearch.h" #include "stringlib/count.h" #include "stringlib/find.h" #include "stringlib/undef.h" +_Py_COMP_DIAG_POP /* --- Unicode Object ----------------------------------------------------- */ @@ -4087,6 +4097,11 @@ PyUnicode_AsUnicodeAndSize(PyObject *unicode, Py_ssize_t *size) return w; } +/* Deprecated APIs */ + +_Py_COMP_DIAG_PUSH +_Py_COMP_DIAG_IGNORE_DEPR_DECLS + Py_UNICODE * PyUnicode_AsUnicode(PyObject *unicode) { @@ -4125,6 +4140,8 @@ PyUnicode_GetSize(PyObject *unicode) return -1; } +_Py_COMP_DIAG_POP + Py_ssize_t PyUnicode_GetLength(PyObject *unicode) { @@ -12352,6 +12369,8 @@ PyUnicode_IsIdentifier(PyObject *self) return len && i == len; } else { +_Py_COMP_DIAG_PUSH +_Py_COMP_DIAG_IGNORE_DEPR_DECLS Py_ssize_t i = 0, len = PyUnicode_GET_SIZE(self); if (len == 0) { /* an empty string is not a valid identifier */ @@ -12389,6 +12408,7 @@ PyUnicode_IsIdentifier(PyObject *self) } } return 1; +_Py_COMP_DIAG_POP } } @@ -15944,7 +15964,10 @@ PyUnicode_AsUnicodeCopy(PyObject *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. */ |