Skip to content

Commit 4913e8a

Browse files
committed
gh-154757: Remove the deprecated Py_UNICODE type
Py_UNICODE was a typedef to wchar_t, deprecated by PEP 393 since Python 3.3 and at runtime since Python 3.13, and scheduled for removal in 3.16. Nothing in CPython used it: the Argument Clinic converter of the same name generates const wchar_t *, and the typedef is not part of the stable ABI. The documentation references to it are kept, with the link suppressed, as was done for PyWeakref_GetObject in GH-133657.
1 parent 993a0c6 commit 4913e8a

8 files changed

Lines changed: 18 additions & 27 deletions

File tree

Doc/c-api/unicode.rst

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ points must be below 1114112 (which is the full Unicode range).
1717
UTF-8 representation is created on demand and cached in the Unicode object.
1818

1919
.. note::
20-
The :c:type:`Py_UNICODE` representation has been removed since Python 3.12
20+
The :c:type:`!Py_UNICODE` representation has been removed since Python 3.12
2121
with deprecated APIs.
2222
See :pep:`623` for more information.
2323

@@ -1943,20 +1943,6 @@ Deprecated API
19431943
19441944
The following API is deprecated.
19451945
1946-
.. c:type:: Py_UNICODE
1947-
1948-
This is a typedef of :c:type:`wchar_t`, which is a 16-bit type or 32-bit type
1949-
depending on the platform.
1950-
Please use :c:type:`wchar_t` directly instead.
1951-
1952-
.. versionchanged:: 3.3
1953-
In previous versions, this was a 16-bit type or a 32-bit type depending on
1954-
whether you selected a "narrow" or "wide" Unicode version of Python at
1955-
build time.
1956-
1957-
.. deprecated-removed:: 3.13 3.16
1958-
1959-
19601946
.. c:function:: int PyUnicode_READY(PyObject *unicode)
19611947
19621948
Do nothing and return ``0``.

Doc/deprecations/c-api-pending-removal-in-3.16.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,3 @@ Pending removal in Python 3.16
8383
The :c:func:`Py_InitializeFromConfig` API should be used with
8484
:c:type:`PyConfig` to set these options. Or :c:func:`PyConfig_Get` can be
8585
used to get these options at runtime.
86-
87-
* :c:type:`Py_UNICODE` which was deprecated by :pep:`393`.

Doc/tools/removed-ids.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ deprecations/index.html: c-api-pending-removal-in-python-3-16
2020
using/configure.html: cmdoption-with-system-libmpdec
2121

2222
# Removed APIs
23+
c-api/unicode.html: c.Py_UNICODE
2324
library/symtable.html: symtable.Class.get_methods
2425
library/sys.html: sys._enablelegacywindowsfsencoding
2526
c-api/import.html: c.PyImport_LazyImportsMode.PyImport_LAZY_NONE

Doc/whatsnew/3.11.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2689,7 +2689,7 @@ Removed
26892689

26902690
.. _whatsnew311-pep624:
26912691

2692-
* Remove the :c:type:`Py_UNICODE` encoder APIs,
2692+
* Remove the :c:type:`!Py_UNICODE` encoder APIs,
26932693
as they have been deprecated since Python 3.3,
26942694
are little used
26952695
and are inefficient relative to the recommended alternatives.

Doc/whatsnew/3.16.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,3 +841,8 @@ Deprecated C APIs
841841

842842
Removed C APIs
843843
--------------
844+
845+
* Remove the deprecated :c:type:`!Py_UNICODE` type, a typedef to
846+
:c:type:`wchar_t` deprecated by :pep:`393` since Python 3.3 and at runtime
847+
since Python 3.13. Use :c:type:`wchar_t` instead.
848+
(Contributed by Vyron Vasileiadis in :gh:`154757`.)

Doc/whatsnew/3.3.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2265,11 +2265,11 @@ Deprecated Python modules, functions and methods
22652265
Deprecated functions and types of the C API
22662266
-------------------------------------------
22672267

2268-
The :c:type:`Py_UNICODE` has been deprecated by :pep:`393` and will be
2268+
The :c:type:`!Py_UNICODE` has been deprecated by :pep:`393` and will be
22692269
removed in Python 4. All functions using this type are deprecated:
22702270

2271-
Unicode functions and methods using :c:type:`Py_UNICODE` and
2272-
:c:expr:`Py_UNICODE*` types:
2271+
Unicode functions and methods using :c:type:`!Py_UNICODE` and
2272+
``Py_UNICODE*`` types:
22732273

22742274
* :c:macro:`!PyUnicode_FromUnicode`: use :c:func:`PyUnicode_FromWideChar` or
22752275
:c:func:`PyUnicode_FromKindAndData`
@@ -2329,7 +2329,7 @@ Deprecated features
23292329
-------------------
23302330

23312331
The :mod:`array` module's ``'u'`` format code is now deprecated and will be
2332-
removed in Python 4 together with the rest of the (:c:type:`Py_UNICODE`) API.
2332+
removed in Python 4 together with the rest of the (:c:type:`!Py_UNICODE`) API.
23332333

23342334

23352335
Porting to Python 3.3
@@ -2470,7 +2470,7 @@ Porting C code
24702470
All extensions relying on the relevant parts in ``memoryobject.h``
24712471
or ``object.h`` must be rebuilt.
24722472

2473-
* Due to :ref:`PEP 393 <pep-393>`, the :c:type:`Py_UNICODE` type and all
2473+
* Due to :ref:`PEP 393 <pep-393>`, the :c:type:`!Py_UNICODE` type and all
24742474
functions using this type are deprecated (but will stay available for
24752475
at least five years). If you were using low-level Unicode APIs to
24762476
construct and access unicode objects and you want to benefit of the

Include/cpython/unicodeobject.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22
# error "this header file must not be included directly"
33
#endif
44

5-
/* Py_UNICODE was the native Unicode storage format (code unit) used by
5+
/* PY_UNICODE_TYPE was the native Unicode storage format (code unit) used by
66
Python and represents a single Unicode element in the Unicode type.
7-
With PEP 393, Py_UNICODE is deprecated and replaced with a
8-
typedef to wchar_t. */
7+
With PEP 393, it is deprecated and replaced with a typedef to wchar_t. */
98
Py_DEPRECATED(3.13) typedef wchar_t PY_UNICODE_TYPE;
10-
Py_DEPRECATED(3.13) typedef wchar_t Py_UNICODE;
119

1210

1311
/* --- Internal Unicode Operations ---------------------------------------- */
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Remove the deprecated :c:type:`!Py_UNICODE` type. It was a typedef to
2+
:c:type:`wchar_t`, deprecated by :pep:`393` since Python 3.3 and at runtime
3+
since Python 3.13. Use :c:type:`wchar_t` instead.

0 commit comments

Comments
 (0)