Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
bpo-36346: Add Py_DEPRECATED to deprecated unicode APIs#20878
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
b7bb1694e887188f582646b9d12c10e1b13a703182468a43b52802fe6e86236b9fa49a30bed2d4490cc78c2daaecae480426cb789439048935d68dbb3ee751File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -46,13 +46,17 @@ | ||||||
| Py_UNICODE_ISDIGIT(ch) || \ | ||||||
| Py_UNICODE_ISNUMERIC(ch)) | ||||||
| #definePy_UNICODE_COPY(target, source, length) \ | ||||||
| memcpy((target), (source), (length)*sizeof(Py_UNICODE)) | ||||||
| #definePy_UNICODE_FILL(target, value, length) \ | ||||||
| do{Py_ssize_t i_; Py_UNICODE *t_ = (target); Py_UNICODE v_ = (value);\ | ||||||
| for (i_ = 0; i_ < (length); i_++) t_[i_] = v_;\ | ||||||
| } while (0) | ||||||
| Py_DEPRECATED(3.3) static inline void | ||||||
| Py_UNICODE_COPY(Py_UNICODE *target, const Py_UNICODE *source, Py_ssize_t length){ | ||||||
| memcpy(target, source, length * sizeof(Py_UNICODE)); | ||||||
| } | ||||||
| Py_DEPRECATED(3.3) static inline void | ||||||
| Py_UNICODE_FILL(Py_UNICODE *target, Py_UNICODE value, Py_ssize_t length){ | ||||||
| for (Py_ssize_t i = 0; i < length; i++){ | ||||||
| target[i] = value; | ||||||
| } | ||||||
| } | ||||||
| /* macros to work with surrogates */ | ||||||
| #definePy_UNICODE_IS_SURROGATE(ch) (0xD800 <= (ch) && (ch) <= 0xDFFF) | ||||||
| @@ -67,14 +71,6 @@ | ||||||
| /* low surrogate = bottom 10 bits added to DC00 */ | ||||||
| #definePy_UNICODE_LOW_SURROGATE(ch) (0xDC00 + ((ch) & 0x3FF)) | ||||||
| /* Check if substring matches at given offset. The offset must be | ||||||
| valid, and the substring must not be empty. */ | ||||||
| #definePy_UNICODE_MATCH(string, offset, substring) \ | ||||||
| ((*((string)->wstr + (offset)) == *((substring)->wstr)) && \ | ||||||
| ((*((string)->wstr + (offset) + (substring)->wstr_length-1) == *((substring)->wstr + (substring)->wstr_length-1))) && \ | ||||||
| !memcmp((string)->wstr + (offset), (substring)->wstr, (substring)->wstr_length*sizeof(Py_UNICODE))) | ||||||
| /* --- Unicode Type ------------------------------------------------------- */ | ||||||
| /* ASCII-only strings created through PyUnicode_New use the PyASCIIObject | ||||||
| @@ -247,10 +243,6 @@ PyAPI_FUNC(int) _PyUnicode_CheckConsistency( | ||||||
| int check_content); | ||||||
| /* Fast access macros */ | ||||||
| #definePyUnicode_WSTR_LENGTH(op) \ | ||||||
methane marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||||||
| (PyUnicode_IS_COMPACT_ASCII(op) ? \ | ||||||
| ((PyASCIIObject*)op)->length : \ | ||||||
| ((PyCompactUnicodeObject*)op)->wstr_length) | ||||||
| /* Returns the deprecated Py_UNICODE representation's size in code units | ||||||
| (this includes surrogate pairs as 2 units). | ||||||
| @@ -445,6 +437,14 @@ enum PyUnicode_Kind{ | ||||||
| (0xffffU) : \ | ||||||
| (0x10ffffU))))) | ||||||
| Py_DEPRECATED(3.3) | ||||||
| static inline Py_ssize_t _PyUnicode_get_wstr_length(PyObject *op){ | ||||||
| returnPyUnicode_IS_COMPACT_ASCII(op) ? | ||||||
| ((PyASCIIObject*)op)->length : | ||||||
| ((PyCompactUnicodeObject*)op)->wstr_length; | ||||||
| } | ||||||
| #definePyUnicode_WSTR_LENGTH(op) _PyUnicode_get_wstr_length((PyObject*)op) | ||||||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You might use _PyObject_CAST() macro: Suggested change
| ||||||
| /* === Public API ========================================================= */ | ||||||
| /* --- Plain Py_UNICODE --------------------------------------------------- */ | ||||||
| @@ -543,7 +543,7 @@ PyAPI_FUNC(void) _PyUnicode_FastFill( | ||||||
| only allowed if u was set to NULL. | ||||||
| The buffer is copied into the new object. */ | ||||||
| /*Py_DEPRECATED(3.3)*/ PyAPI_FUNC(PyObject*) PyUnicode_FromUnicode( | ||||||
| Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_FromUnicode( | ||||||
| const Py_UNICODE *u, /* Unicode buffer */ | ||||||
| Py_ssize_t size /* size of buffer */ | ||||||
| ); | ||||||
| @@ -572,13 +572,13 @@ PyAPI_FUNC(Py_UCS4) _PyUnicode_FindMaxChar ( | ||||||
| Py_UNICODE buffer. | ||||||
| If the wchar_t/Py_UNICODE representation is not yet available, this | ||||||
| function will calculate it. */ | ||||||
| /*Py_DEPRECATED(3.3)*/ PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode( | ||||||
| Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode( | ||||||
| PyObject *unicode /* Unicode object */ | ||||||
| ); | ||||||
| /* Similar to PyUnicode_AsUnicode(), but raises a ValueError if the string | ||||||
| contains null characters. */ | ||||||
| PyAPI_FUNC(const Py_UNICODE *) _PyUnicode_AsUnicode( | ||||||
| Py_DEPRECATED(3.3) PyAPI_FUNC(const Py_UNICODE *) _PyUnicode_AsUnicode( | ||||||
| PyObject *unicode /* Unicode object */ | ||||||
| ); | ||||||
| @@ -587,7 +587,7 @@ PyAPI_FUNC(const Py_UNICODE *) _PyUnicode_AsUnicode( | ||||||
| If the wchar_t/Py_UNICODE representation is not yet available, this | ||||||
| function will calculate it. */ | ||||||
| /*Py_DEPRECATED(3.3)*/ PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicodeAndSize( | ||||||
| Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicodeAndSize( | ||||||
| PyObject *unicode, /* Unicode object */ | ||||||
| Py_ssize_t *size /* location where to save the length */ | ||||||
| ); | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Mark ``Py_UNICODE_COPY``, ``Py_UNICODE_FILL``, ``PyUnicode_WSTR_LENGTH``, | ||
| ``PyUnicode_FromUnicode``, ``PyUnicode_AsUnicode``, ``_PyUnicode_AsUnicode``, | ||
| and ``PyUnicode_AsUnicodeAndSize`` as deprecated in C. Remove ``Py_UNICODE_MATCH`` | ||
| which was deprecated and broken since Python 3.3. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1668,6 +1668,10 @@ parse_tuple_and_keywords(PyObject *self, PyObject *args) | ||
| staticvolatileintx; | ||
| /* Ignore use of deprecated APIs */ | ||
| _Py_COMP_DIAG_PUSH | ||
| _Py_COMP_DIAG_IGNORE_DEPR_DECLS | ||
methane marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| /* Test the u and u# codes for PyArg_ParseTuple. May leak memory in case | ||
| of an error. | ||
| */ | ||
| @@ -1844,6 +1848,7 @@ test_widechar(PyObject *self, PyObject *Py_UNUSED(ignored)) | ||
| Py_RETURN_NONE; | ||
| } | ||
| _Py_COMP_DIAG_POP | ||
| staticPyObject* | ||
| unicode_aswidechar(PyObject*self, PyObject*args) | ||
| @@ -2064,6 +2069,10 @@ unicode_transformdecimaltoascii(PyObject *self, PyObject *args) | ||
| returnPyUnicode_TransformDecimalToASCII(unicode, length); | ||
| } | ||
| /* Ignore use of deprecated APIs */ | ||
| _Py_COMP_DIAG_PUSH | ||
| _Py_COMP_DIAG_IGNORE_DEPR_DECLS | ||
| staticPyObject* | ||
| unicode_legacy_string(PyObject*self, PyObject*args) | ||
| { | ||
| @@ -2086,6 +2095,7 @@ unicode_legacy_string(PyObject *self, PyObject *args) | ||
| returnu; | ||
| } | ||
| _Py_COMP_DIAG_POP | ||
| staticPyObject* | ||
| getargs_w_star(PyObject*self, PyObject*args) | ||
Uh oh!
There was an error while loading. Please reload this page.