4646 Py_UNICODE_ISDIGIT(ch) || \
4747 Py_UNICODE_ISNUMERIC(ch))
4848
49- #define Py_UNICODE_COPY (target, source, length ) \
50- memcpy ((target), (source), (length)*sizeof(Py_UNICODE))
51-
52- #define Py_UNICODE_FILL (target, value, length ) \
53- do {Py_ssize_t i_; Py_UNICODE *t_ = (target); Py_UNICODE v_ = (value);\
54- for (i_ = 0 ; i_ < (length); i_++) t_[i_] = v_;\
55- } while (0 )
49+ Py_DEPRECATED(3.3 ) static inline void
50+ Py_UNICODE_COPY(Py_UNICODE *target, const Py_UNICODE *source, Py_ssize_t length) {
51+ memcpy (target, source, length * sizeof (Py_UNICODE));
52+ }
53+
54+ Py_DEPRECATED (3.3 ) static inline void
55+ Py_UNICODE_FILL(Py_UNICODE *target, Py_UNICODE value, Py_ssize_t length) {
56+ for (Py_ssize_t i = 0 ; i < length; i++) {
57+ target[i] = value;
58+ }
59+ }
5660
5761/* macros to work with surrogates */
5862#define Py_UNICODE_IS_SURROGATE (ch ) (0xD800 <= (ch) && (ch) <= 0xDFFF )
6771/* low surrogate = bottom 10 bits added to DC00 */
6872#define Py_UNICODE_LOW_SURROGATE (ch ) (0xDC00 + ((ch) & 0x3FF ))
6973
70- /* Check if substring matches at given offset. The offset must be
71- valid, and the substring must not be empty. */
72-
73- #define Py_UNICODE_MATCH (string, offset, substring ) \
74- ((*((string)->wstr + (offset)) == *((substring)->wstr)) && \
75- ((*((string)->wstr + (offset) + (substring)->wstr_length-1 ) == *((substring)->wstr + (substring)->wstr_length-1 ))) && \
76- !memcmp((string)->wstr + (offset), (substring)->wstr, (substring)->wstr_length*sizeof (Py_UNICODE)))
77-
7874/* --- Unicode Type ------------------------------------------------------- */
7975
8076/* ASCII-only strings created through PyUnicode_New use the PyASCIIObject
@@ -247,10 +243,6 @@ PyAPI_FUNC(int) _PyUnicode_CheckConsistency(
247243 int check_content);
248244
249245/* Fast access macros */
250- #define PyUnicode_WSTR_LENGTH (op ) \
251- (PyUnicode_IS_COMPACT_ASCII(op) ? \
252- ((PyASCIIObject*)op)->length : \
253- ((PyCompactUnicodeObject*)op)->wstr_length)
254246
255247/* Returns the deprecated Py_UNICODE representation's size in code units
256248 (this includes surrogate pairs as 2 units).
@@ -445,6 +437,14 @@ enum PyUnicode_Kind {
445437 (0xffffU ) : \
446438 (0x10ffffU )))))
447439
440+ Py_DEPRECATED (3.3 )
441+ static inline Py_ssize_t _PyUnicode_get_wstr_length(PyObject *op) {
442+ return PyUnicode_IS_COMPACT_ASCII (op) ?
443+ ((PyASCIIObject*)op)->length :
444+ ((PyCompactUnicodeObject*)op)->wstr_length ;
445+ }
446+ #define PyUnicode_WSTR_LENGTH (op ) _PyUnicode_get_wstr_length((PyObject*)op)
447+
448448/* === Public API ========================================================= */
449449
450450/* --- Plain Py_UNICODE --------------------------------------------------- */
@@ -543,7 +543,7 @@ PyAPI_FUNC(void) _PyUnicode_FastFill(
543543 only allowed if u was set to NULL.
544544
545545 The buffer is copied into the new object. */
546- /* Py_DEPRECATED(3.3) */ PyAPI_FUNC(PyObject*) PyUnicode_FromUnicode(
546+ Py_DEPRECATED (3.3 ) PyAPI_FUNC(PyObject*) PyUnicode_FromUnicode(
547547 const Py_UNICODE *u, /* Unicode buffer */
548548 Py_ssize_t size /* size of buffer */
549549 );
@@ -572,13 +572,13 @@ PyAPI_FUNC(Py_UCS4) _PyUnicode_FindMaxChar (
572572 Py_UNICODE buffer.
573573 If the wchar_t/Py_UNICODE representation is not yet available, this
574574 function will calculate it. */
575- /* Py_DEPRECATED(3.3) */ PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode(
575+ Py_DEPRECATED (3.3 ) PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode(
576576 PyObject *unicode /* Unicode object */
577577 );
578578
579579/* Similar to PyUnicode_AsUnicode(), but raises a ValueError if the string
580580 contains null characters. */
581- PyAPI_FUNC (const Py_UNICODE *) _PyUnicode_AsUnicode(
581+ Py_DEPRECATED ( 3.3 ) PyAPI_FUNC(const Py_UNICODE *) _PyUnicode_AsUnicode(
582582 PyObject *unicode /* Unicode object */
583583 );
584584
@@ -587,7 +587,7 @@ PyAPI_FUNC(const Py_UNICODE *) _PyUnicode_AsUnicode(
587587 If the wchar_t/Py_UNICODE representation is not yet available, this
588588 function will calculate it. */
589589
590- /* Py_DEPRECATED(3.3) */ PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicodeAndSize(
590+ Py_DEPRECATED (3.3 ) PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicodeAndSize(
591591 PyObject *unicode, /* Unicode object */
592592 Py_ssize_t *size /* location where to save the length */
593593 );
0 commit comments