whether you selected a "narrow" or "wide" Unicode version of Python at
build time.
+ .. deprecated-removed:: 3.13 3.15
+
.. c:type:: PyASCIIObject
PyCompactUnicodeObject
Deprecated
----------
+* Deprecate the old ``Py_UNICODE`` and ``PY_UNICODE_TYPE`` types: use directly
+ the ``wchar_t`` type instead. Since Python 3.3, ``Py_UNICODE`` and
+ ``PY_UNICODE_TYPE`` are just aliases to ``wchar_t``.
+ (Contributed by Victor Stinner in :gh:`105156`.)
+
Removed
-------
Python and represents a single Unicode element in the Unicode type.
With PEP 393, Py_UNICODE is deprecated and replaced with a
typedef to wchar_t. */
-#define PY_UNICODE_TYPE wchar_t
-/* Py_DEPRECATED(3.3) */ typedef wchar_t Py_UNICODE;
+Py_DEPRECATED(3.13) typedef wchar_t PY_UNICODE_TYPE;
+Py_DEPRECATED(3.13) typedef wchar_t Py_UNICODE;
/* --- Internal Unicode Operations ---------------------------------------- */
--- /dev/null
+Deprecate the old ``Py_UNICODE`` and ``PY_UNICODE_TYPE`` types: use directly
+the ``wchar_t`` type instead. Since Python 3.3, ``Py_UNICODE`` and
+``PY_UNICODE_TYPE`` are just aliases to ``wchar_t``. Patch by Victor
+Stinner.
/*[clinic end generated code: output=23413f68e6484bbd input=588aac967e0ba74b]*/
{
#ifdef MS_WINDOWS
- Py_UNICODE *widename = NULL;
+ wchar_t *widename = NULL;
#else
const char *name = NULL;
#endif
static PyObject *
getargs_u(PyObject *self, PyObject *args)
{
- Py_UNICODE *str;
+ wchar_t *str;
if (!PyArg_ParseTuple(args, "u", &str)) {
return NULL;
}
static PyObject *
getargs_u_hash(PyObject *self, PyObject *args)
{
- Py_UNICODE *str;
+ wchar_t *str;
Py_ssize_t size;
if (!PyArg_ParseTuple(args, "u#", &str, &size)) {
return NULL;
static PyObject *
getargs_Z(PyObject *self, PyObject *args)
{
- Py_UNICODE *str;
+ wchar_t *str;
if (!PyArg_ParseTuple(args, "Z", &str)) {
return NULL;
}
static PyObject *
getargs_Z_hash(PyObject *self, PyObject *args)
{
- Py_UNICODE *str;
+ wchar_t *str;
Py_ssize_t size;
if (!PyArg_ParseTuple(args, "Z#", &str, &size)) {
return NULL;
return UNSIGNED_INT8;
case 'u':
- if (sizeof(Py_UNICODE) == 2) {
+ if (sizeof(wchar_t) == 2) {
return UTF16_LE + is_big_endian;
}
- if (sizeof(Py_UNICODE) == 4) {
+ if (sizeof(wchar_t) == 4) {
return UTF32_LE + is_big_endian;
}
return UNKNOWN_FORMAT;
switch (PyUnicode_KIND(unicode)) {
case PyUnicode_1BYTE_KIND:
- _PyUnicode_CONVERT_BYTES(Py_UNICODE, unsigned char,
+ _PyUnicode_CONVERT_BYTES(wchar_t, unsigned char,
u, u + size, PyUnicode_1BYTE_DATA(unicode));
break;
case PyUnicode_2BYTE_KIND:
#if Py_UNICODE_SIZE == 2
memcpy(PyUnicode_2BYTE_DATA(unicode), u, size * 2);
#else
- _PyUnicode_CONVERT_BYTES(Py_UNICODE, Py_UCS2,
+ _PyUnicode_CONVERT_BYTES(wchar_t, Py_UCS2,
u, u + size, PyUnicode_2BYTE_DATA(unicode));
#endif
break;
PyUnicode_GetSize() has been deprecated since Python 3.3
because it returned length of Py_UNICODE.
-But this function is part of stable abi, because it don't
+But this function is part of stable abi, because it doesn't
include Py_UNICODE in signature and it was not excluded from
-stable abi in PEP 384.
+stable ABI in PEP 384.
*/
PyAPI_FUNC(Py_ssize_t)
PyUnicode_GetSize(PyObject *unicode)
case 'u':
{
PyObject *v;
- Py_UNICODE *u = va_arg(*p_va, Py_UNICODE *);
+ const wchar_t *u = va_arg(*p_va, wchar_t*);
Py_ssize_t n;
if (**p_format == '#') {
++*p_format;