Skip to content

Commit 42ec190

Browse files
authored
bpo-33195: Doc: Deprecate Py_UNICODE in c-api/arg (GH-6329)
Py_UNICODE is deprecated since Python 3.3. But the deprecation is missed in the c-api/arg document.
1 parent dfbbbf1 commit 42ec190

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

Doc/c-api/arg.rst

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,19 +151,35 @@ which disallows mutable objects such as :class:`bytearray`.
151151
Previously, :exc:`TypeError` was raised when embedded null code points
152152
were encountered in the Python string.
153153

154+
.. deprecated-removed:: 3.3 4.0
155+
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
156+
:c:func:`PyUnicode_AsWideCharString`.
157+
154158
``u#`` (:class:`str`) [const Py_UNICODE \*, int]
155159
This variant on ``u`` stores into two C variables, the first one a pointer to a
156160
Unicode data buffer, the second one its length. This variant allows
157161
null code points.
158162

163+
.. deprecated-removed:: 3.3 4.0
164+
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
165+
:c:func:`PyUnicode_AsWideCharString`.
166+
159167
``Z`` (:class:`str` or ``None``) [const Py_UNICODE \*]
160168
Like ``u``, but the Python object may also be ``None``, in which case the
161169
:c:type:`Py_UNICODE` pointer is set to *NULL*.
162170

171+
.. deprecated-removed:: 3.3 4.0
172+
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
173+
:c:func:`PyUnicode_AsWideCharString`.
174+
163175
``Z#`` (:class:`str` or ``None``) [const Py_UNICODE \*, int]
164176
Like ``u#``, but the Python object may also be ``None``, in which case the
165177
:c:type:`Py_UNICODE` pointer is set to *NULL*.
166178

179+
.. deprecated-removed:: 3.3 4.0
180+
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
181+
:c:func:`PyUnicode_AsWideCharString`.
182+
167183
``U`` (:class:`str`) [PyObject \*]
168184
Requires that the Python object is a Unicode object, without attempting
169185
any conversion. Raises :exc:`TypeError` if the object is not a Unicode
@@ -552,12 +568,13 @@ Building values
552568
``z#`` (:class:`str` or ``None``) [const char \*, int]
553569
Same as ``s#``.
554570
555-
``u`` (:class:`str`) [const Py_UNICODE \*]
556-
Convert a null-terminated buffer of Unicode (UCS-2 or UCS-4) data to a Python
557-
Unicode object. If the Unicode buffer pointer is *NULL*, ``None`` is returned.
571+
``u`` (:class:`str`) [const wchar_t \*]
572+
Convert a null-terminated :c:type:`wchar_t` buffer of Unicode (UTF-16 or UCS-4)
573+
data to a Python Unicode object. If the Unicode buffer pointer is *NULL*,
574+
``None`` is returned.
558575
559-
``u#`` (:class:`str`) [const Py_UNICODE \*, int]
560-
Convert a Unicode (UCS-2 or UCS-4) data buffer and its length to a Python
576+
``u#`` (:class:`str`) [const wchar_t \*, int]
577+
Convert a Unicode (UTF-16 or UCS-4) data buffer and its length to a Python
561578
Unicode object. If the Unicode buffer pointer is *NULL*, the length is ignored
562579
and ``None`` is returned.
563580
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Deprecate ``Py_UNICODE`` usage in ``c-api/arg`` document. ``Py_UNICODE``
2+
related APIs are deprecated since Python 3.3, but it is missed in the
3+
document.

0 commit comments

Comments
 (0)