Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-44029: Remove Py_UNICODE APIs #25881

Merged
merged 15 commits into from
May 7, 2021
Merged
21 changes: 0 additions & 21 deletions Doc/c-api/exceptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -675,27 +675,6 @@ The following functions are used to create and modify Unicode exceptions from C.
*object*, *length*, *start*, *end* and *reason*. *encoding* and *reason* are
UTF-8 encoded strings.

.. c:function:: PyObject* PyUnicodeEncodeError_Create(const char *encoding, const Py_UNICODE *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason)

Create a :class:`UnicodeEncodeError` object with the attributes *encoding*,
*object*, *length*, *start*, *end* and *reason*. *encoding* and *reason* are
UTF-8 encoded strings.

.. deprecated:: 3.3 3.11

``Py_UNICODE`` is deprecated since Python 3.3. Please migrate to
``PyObject_CallFunction(PyExc_UnicodeEncodeError, "sOnns", ...)``.

.. c:function:: PyObject* PyUnicodeTranslateError_Create(const Py_UNICODE *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason)

Create a :class:`UnicodeTranslateError` object with the attributes *object*,
*length*, *start*, *end* and *reason*. *reason* is a UTF-8 encoded string.

.. deprecated:: 3.3 3.11

``Py_UNICODE`` is deprecated since Python 3.3. Please migrate to
``PyObject_CallFunction(PyExc_UnicodeTranslateError, "Onns", ...)``.

.. c:function:: PyObject* PyUnicodeDecodeError_GetEncoding(PyObject *exc)
PyObject* PyUnicodeEncodeError_GetEncoding(PyObject *exc)

Expand Down
185 changes: 0 additions & 185 deletions Doc/c-api/unicode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -719,17 +719,6 @@ Extension modules can continue using them, as they will not be removed in Python
:c:func:`PyUnicode_ReadChar` or similar new APIs.


.. c:function:: PyObject* PyUnicode_TransformDecimalToASCII(Py_UNICODE *s, Py_ssize_t size)

Create a Unicode object by replacing all decimal digits in
:c:type:`Py_UNICODE` buffer of the given *size* by ASCII digits 0--9
according to their decimal value. Return ``NULL`` if an exception occurs.

.. deprecated-removed:: 3.3 3.11
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
:c:func:`Py_UNICODE_TODECIMAL`.


.. c:function:: Py_UNICODE* PyUnicode_AsUnicodeAndSize(PyObject *unicode, Py_ssize_t *size)

Like :c:func:`PyUnicode_AsUnicode`, but also saves the :c:func:`Py_UNICODE`
Expand Down Expand Up @@ -1038,20 +1027,6 @@ These are the generic codec APIs:
the codec.


.. c:function:: PyObject* PyUnicode_Encode(const Py_UNICODE *s, Py_ssize_t size, \
const char *encoding, const char *errors)

Encode the :c:type:`Py_UNICODE` buffer *s* of the given *size* and return a Python
bytes object. *encoding* and *errors* have the same meaning as the
parameters of the same name in the Unicode :meth:`~str.encode` method. The codec
to be used is looked up using the Python codec registry. Return ``NULL`` if an
exception was raised by the codec.

.. deprecated-removed:: 3.3 3.11
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
:c:func:`PyUnicode_AsEncodedString`.


UTF-8 Codecs
""""""""""""

Expand Down Expand Up @@ -1114,18 +1089,6 @@ These are the UTF-8 codec APIs:
The return type is now ``const char *`` rather of ``char *``.


.. c:function:: PyObject* PyUnicode_EncodeUTF8(const Py_UNICODE *s, Py_ssize_t size, const char *errors)

Encode the :c:type:`Py_UNICODE` buffer *s* of the given *size* using UTF-8 and
return a Python bytes object. Return ``NULL`` if an exception was raised by
the codec.

.. deprecated-removed:: 3.3 3.11
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
:c:func:`PyUnicode_AsUTF8String`, :c:func:`PyUnicode_AsUTF8AndSize` or
:c:func:`PyUnicode_AsEncodedString`.


UTF-32 Codecs
"""""""""""""

Expand Down Expand Up @@ -1176,29 +1139,6 @@ These are the UTF-32 codec APIs:
Return ``NULL`` if an exception was raised by the codec.


.. c:function:: PyObject* PyUnicode_EncodeUTF32(const Py_UNICODE *s, Py_ssize_t size, \
const char *errors, int byteorder)

Return a Python bytes object holding the UTF-32 encoded value of the Unicode
data in *s*. Output is written according to the following byte order::

byteorder == -1: little endian
byteorder == 0: native byte order (writes a BOM mark)
byteorder == 1: big endian

If byteorder is ``0``, the output string will always start with the Unicode BOM
mark (U+FEFF). In the other two modes, no BOM mark is prepended.

If ``Py_UNICODE_WIDE`` is not defined, surrogate pairs will be output
as a single code point.

Return ``NULL`` if an exception was raised by the codec.

.. deprecated-removed:: 3.3 3.11
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
:c:func:`PyUnicode_AsUTF32String` or :c:func:`PyUnicode_AsEncodedString`.


UTF-16 Codecs
"""""""""""""

Expand Down Expand Up @@ -1250,30 +1190,6 @@ These are the UTF-16 codec APIs:
Return ``NULL`` if an exception was raised by the codec.


.. c:function:: PyObject* PyUnicode_EncodeUTF16(const Py_UNICODE *s, Py_ssize_t size, \
const char *errors, int byteorder)

Return a Python bytes object holding the UTF-16 encoded value of the Unicode
data in *s*. Output is written according to the following byte order::

byteorder == -1: little endian
byteorder == 0: native byte order (writes a BOM mark)
byteorder == 1: big endian

If byteorder is ``0``, the output string will always start with the Unicode BOM
mark (U+FEFF). In the other two modes, no BOM mark is prepended.

If ``Py_UNICODE_WIDE`` is defined, a single :c:type:`Py_UNICODE` value may get
represented as a surrogate pair. If it is not defined, each :c:type:`Py_UNICODE`
values is interpreted as a UCS-2 character.

Return ``NULL`` if an exception was raised by the codec.

.. deprecated-removed:: 3.3 3.11
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
:c:func:`PyUnicode_AsUTF16String` or :c:func:`PyUnicode_AsEncodedString`.


UTF-7 Codecs
""""""""""""

Expand All @@ -1295,23 +1211,6 @@ These are the UTF-7 codec APIs:
bytes that have been decoded will be stored in *consumed*.


.. c:function:: PyObject* PyUnicode_EncodeUTF7(const Py_UNICODE *s, Py_ssize_t size, \
int base64SetO, int base64WhiteSpace, const char *errors)

Encode the :c:type:`Py_UNICODE` buffer of the given size using UTF-7 and
return a Python bytes object. Return ``NULL`` if an exception was raised by
the codec.

If *base64SetO* is nonzero, "Set O" (punctuation that has no otherwise
special meaning) will be encoded in base-64. If *base64WhiteSpace* is
nonzero, whitespace will be encoded in base-64. Both are set to zero for the
Python "utf-7" codec.

.. deprecated-removed:: 3.3 3.11
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
:c:func:`PyUnicode_AsEncodedString`.


Unicode-Escape Codecs
"""""""""""""""""""""

Expand All @@ -1332,16 +1231,6 @@ These are the "Unicode Escape" codec APIs:
raised by the codec.


.. c:function:: PyObject* PyUnicode_EncodeUnicodeEscape(const Py_UNICODE *s, Py_ssize_t size)

Encode the :c:type:`Py_UNICODE` buffer of the given *size* using Unicode-Escape and
return a bytes object. Return ``NULL`` if an exception was raised by the codec.

.. deprecated-removed:: 3.3 3.11
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
:c:func:`PyUnicode_AsUnicodeEscapeString`.


Raw-Unicode-Escape Codecs
"""""""""""""""""""""""""

Expand All @@ -1362,18 +1251,6 @@ These are the "Raw Unicode Escape" codec APIs:
was raised by the codec.


.. c:function:: PyObject* PyUnicode_EncodeRawUnicodeEscape(const Py_UNICODE *s, \
Py_ssize_t size)

Encode the :c:type:`Py_UNICODE` buffer of the given *size* using Raw-Unicode-Escape
and return a bytes object. Return ``NULL`` if an exception was raised by the codec.

.. deprecated-removed:: 3.3 3.11
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
:c:func:`PyUnicode_AsRawUnicodeEscapeString` or
:c:func:`PyUnicode_AsEncodedString`.


Latin-1 Codecs
""""""""""""""

Expand All @@ -1394,18 +1271,6 @@ ordinals and only these are accepted by the codecs during encoding.
raised by the codec.


.. c:function:: PyObject* PyUnicode_EncodeLatin1(const Py_UNICODE *s, Py_ssize_t size, const char *errors)

Encode the :c:type:`Py_UNICODE` buffer of the given *size* using Latin-1 and
return a Python bytes object. Return ``NULL`` if an exception was raised by
the codec.

.. deprecated-removed:: 3.3 3.11
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
:c:func:`PyUnicode_AsLatin1String` or
:c:func:`PyUnicode_AsEncodedString`.


ASCII Codecs
""""""""""""

Expand All @@ -1426,18 +1291,6 @@ codes generate errors.
raised by the codec.


.. c:function:: PyObject* PyUnicode_EncodeASCII(const Py_UNICODE *s, Py_ssize_t size, const char *errors)

Encode the :c:type:`Py_UNICODE` buffer of the given *size* using ASCII and
return a Python bytes object. Return ``NULL`` if an exception was raised by
the codec.

.. deprecated-removed:: 3.3 3.11
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
:c:func:`PyUnicode_AsASCIIString` or
:c:func:`PyUnicode_AsEncodedString`.


Character Map Codecs
""""""""""""""""""""

Expand Down Expand Up @@ -1477,19 +1330,6 @@ These are the mapping codec APIs:
``None`` are treated as "undefined mapping" and cause an error.


.. c:function:: PyObject* PyUnicode_EncodeCharmap(const Py_UNICODE *s, Py_ssize_t size, \
PyObject *mapping, const char *errors)

Encode the :c:type:`Py_UNICODE` buffer of the given *size* using the given
*mapping* object and return the result as a bytes object. Return ``NULL`` if
an exception was raised by the codec.

.. deprecated-removed:: 3.3 3.11
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
:c:func:`PyUnicode_AsCharmapString` or
:c:func:`PyUnicode_AsEncodedString`.


The following codec API is special in that maps Unicode to Unicode.

.. c:function:: PyObject* PyUnicode_Translate(PyObject *str, PyObject *table, const char *errors)
Expand All @@ -1509,19 +1349,6 @@ The following codec API is special in that maps Unicode to Unicode.
use the default error handling.


.. c:function:: PyObject* PyUnicode_TranslateCharmap(const Py_UNICODE *s, Py_ssize_t size, \
PyObject *mapping, const char *errors)

Translate a :c:type:`Py_UNICODE` buffer of the given *size* by applying a
character *mapping* table to it and return the resulting Unicode object.
Return ``NULL`` when an exception was raised by the codec.

.. deprecated-removed:: 3.3 3.11
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
:c:func:`PyUnicode_Translate`. or :ref:`generic codec based API
<codec-registry>`


MBCS codecs for Windows
"""""""""""""""""""""""

Expand Down Expand Up @@ -1561,18 +1388,6 @@ the user settings on the machine running the codec.
.. versionadded:: 3.3


.. c:function:: PyObject* PyUnicode_EncodeMBCS(const Py_UNICODE *s, Py_ssize_t size, const char *errors)

Encode the :c:type:`Py_UNICODE` buffer of the given *size* using MBCS and return
a Python bytes object. Return ``NULL`` if an exception was raised by the
codec.

.. deprecated-removed:: 3.3 4.0
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
:c:func:`PyUnicode_AsMBCSString`, :c:func:`PyUnicode_EncodeCodePage` or
:c:func:`PyUnicode_AsEncodedString`.


Methods & Slots
"""""""""""""""

Expand Down
Loading