[Python-checkins] bpo-41123: Remove Py_UNICODE_COPY() and Py_UNICODE_FILL() (GH-28887)

vstinner webhook-mailer at python.org
Mon Oct 11 17:36:45 EDT 2021


https://github.com/python/cpython/commit/1f316ea3b4fa319eec4f375fb683467b424c964e
commit: 1f316ea3b4fa319eec4f375fb683467b424c964e
branch: main
author: Victor Stinner <vstinner at python.org>
committer: vstinner <vstinner at python.org>
date: 2021-10-11T23:36:37+02:00
summary:

bpo-41123: Remove Py_UNICODE_COPY() and Py_UNICODE_FILL() (GH-28887)

files:
A Misc/NEWS.d/next/C API/2021-10-11-22-58-33.bpo-41123.myrlIp.rst
M Doc/whatsnew/3.11.rst
M Include/cpython/unicodeobject.h

diff --git a/Doc/whatsnew/3.11.rst b/Doc/whatsnew/3.11.rst
index 1455a598e1b3c..0d30fe8b64644 100644
--- a/Doc/whatsnew/3.11.rst
+++ b/Doc/whatsnew/3.11.rst
@@ -591,3 +591,8 @@ Removed
   * ``Py_SET_ERRNO_ON_MATH_ERROR()``
 
   (Contributed by Victor Stinner in :issue:`45412`.)
+
+* Remove ``Py_UNICODE_COPY()`` and ``Py_UNICODE_FILL()`` macros, deprecated
+  since Python 3.3. Use ``PyUnicode_CopyCharacters()`` or ``memcpy()``
+  (``wchar_t*`` string), and ``PyUnicode_Fill()`` functions instead.
+  (Contributed by Victor Stinner in :issue:`41123`.)
diff --git a/Include/cpython/unicodeobject.h b/Include/cpython/unicodeobject.h
index b40e2ea1011f5..0cbdbdbbe0af2 100644
--- a/Include/cpython/unicodeobject.h
+++ b/Include/cpython/unicodeobject.h
@@ -50,19 +50,6 @@
     Py_UNICODE_ISDIGIT(ch) || \
     Py_UNICODE_ISNUMERIC(ch))
 
-Py_DEPRECATED(3.3) static inline void
-Py_UNICODE_COPY(Py_UNICODE *target, const Py_UNICODE *source, Py_ssize_t length) {
-    memcpy(target, source, (size_t)(length) * sizeof(Py_UNICODE));
-}
-
-Py_DEPRECATED(3.3) static inline void
-Py_UNICODE_FILL(Py_UNICODE *target, Py_UNICODE value, Py_ssize_t length) {
-    Py_ssize_t i;
-    for (i = 0; i < length; i++) {
-        target[i] = value;
-    }
-}
-
 /* macros to work with surrogates */
 #define Py_UNICODE_IS_SURROGATE(ch) (0xD800 <= (ch) && (ch) <= 0xDFFF)
 #define Py_UNICODE_IS_HIGH_SURROGATE(ch) (0xD800 <= (ch) && (ch) <= 0xDBFF)
diff --git a/Misc/NEWS.d/next/C API/2021-10-11-22-58-33.bpo-41123.myrlIp.rst b/Misc/NEWS.d/next/C API/2021-10-11-22-58-33.bpo-41123.myrlIp.rst
new file mode 100644
index 0000000000000..3ae302bcea245
--- /dev/null
+++ b/Misc/NEWS.d/next/C API/2021-10-11-22-58-33.bpo-41123.myrlIp.rst	
@@ -0,0 +1,4 @@
+Remove ``Py_UNICODE_COPY()`` and ``Py_UNICODE_FILL()`` macros, deprecated
+since Python 3.3. Use ``PyUnicode_CopyCharacters()`` or ``memcpy()``
+(``wchar_t*`` string), and ``PyUnicode_Fill()`` functions instead. Patch by
+Victor Stinner.



More information about the Python-checkins mailing list