Skip to content

Commit 9ad8f10

Browse files
authored
bpo-44029: Remove Py_UNICODE APIs (GH-25881)
Remove deprecated `Py_UNICODE` APIs: `PyUnicode_Encode`, `PyUnicode_EncodeUTF7`, `PyUnicode_EncodeUTF8`, `PyUnicode_EncodeUTF16`, `PyUnicode_EncodeUTF32`, `PyUnicode_EncodeLatin1`, `PyUnicode_EncodeMBCS`, `PyUnicode_EncodeDecimal`, `PyUnicode_EncodeRawUnicodeEscape`, `PyUnicode_EncodeCharmap`, `PyUnicode_EncodeUnicodeEscape`, `PyUnicode_TransformDecimalToASCII`, `PyUnicode_TranslateCharmap`, `PyUnicodeEncodeError_Create`, `PyUnicodeTranslateError_Create`. See :pep:`393` and :pep:`624` for reference.
1 parent 4ebf4a6 commit 9ad8f10

File tree

11 files changed

+15
-840
lines changed

11 files changed

+15
-840
lines changed

Doc/c-api/exceptions.rst

-21
Original file line numberDiff line numberDiff line change
@@ -675,27 +675,6 @@ The following functions are used to create and modify Unicode exceptions from C.
675675
*object*, *length*, *start*, *end* and *reason*. *encoding* and *reason* are
676676
UTF-8 encoded strings.
677677
678-
.. 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)
679-
680-
Create a :class:`UnicodeEncodeError` object with the attributes *encoding*,
681-
*object*, *length*, *start*, *end* and *reason*. *encoding* and *reason* are
682-
UTF-8 encoded strings.
683-
684-
.. deprecated:: 3.3 3.11
685-
686-
``Py_UNICODE`` is deprecated since Python 3.3. Please migrate to
687-
``PyObject_CallFunction(PyExc_UnicodeEncodeError, "sOnns", ...)``.
688-
689-
.. c:function:: PyObject* PyUnicodeTranslateError_Create(const Py_UNICODE *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason)
690-
691-
Create a :class:`UnicodeTranslateError` object with the attributes *object*,
692-
*length*, *start*, *end* and *reason*. *reason* is a UTF-8 encoded string.
693-
694-
.. deprecated:: 3.3 3.11
695-
696-
``Py_UNICODE`` is deprecated since Python 3.3. Please migrate to
697-
``PyObject_CallFunction(PyExc_UnicodeTranslateError, "Onns", ...)``.
698-
699678
.. c:function:: PyObject* PyUnicodeDecodeError_GetEncoding(PyObject *exc)
700679
PyObject* PyUnicodeEncodeError_GetEncoding(PyObject *exc)
701680

Doc/c-api/unicode.rst

-185
Original file line numberDiff line numberDiff line change
@@ -719,17 +719,6 @@ Extension modules can continue using them, as they will not be removed in Python
719719
:c:func:`PyUnicode_ReadChar` or similar new APIs.
720720
721721
722-
.. c:function:: PyObject* PyUnicode_TransformDecimalToASCII(Py_UNICODE *s, Py_ssize_t size)
723-
724-
Create a Unicode object by replacing all decimal digits in
725-
:c:type:`Py_UNICODE` buffer of the given *size* by ASCII digits 0--9
726-
according to their decimal value. Return ``NULL`` if an exception occurs.
727-
728-
.. deprecated-removed:: 3.3 3.11
729-
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
730-
:c:func:`Py_UNICODE_TODECIMAL`.
731-
732-
733722
.. c:function:: Py_UNICODE* PyUnicode_AsUnicodeAndSize(PyObject *unicode, Py_ssize_t *size)
734723
735724
Like :c:func:`PyUnicode_AsUnicode`, but also saves the :c:func:`Py_UNICODE`
@@ -1038,20 +1027,6 @@ These are the generic codec APIs:
10381027
the codec.
10391028
10401029
1041-
.. c:function:: PyObject* PyUnicode_Encode(const Py_UNICODE *s, Py_ssize_t size, \
1042-
const char *encoding, const char *errors)
1043-
1044-
Encode the :c:type:`Py_UNICODE` buffer *s* of the given *size* and return a Python
1045-
bytes object. *encoding* and *errors* have the same meaning as the
1046-
parameters of the same name in the Unicode :meth:`~str.encode` method. The codec
1047-
to be used is looked up using the Python codec registry. Return ``NULL`` if an
1048-
exception was raised by the codec.
1049-
1050-
.. deprecated-removed:: 3.3 3.11
1051-
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
1052-
:c:func:`PyUnicode_AsEncodedString`.
1053-
1054-
10551030
UTF-8 Codecs
10561031
""""""""""""
10571032
@@ -1114,18 +1089,6 @@ These are the UTF-8 codec APIs:
11141089
The return type is now ``const char *`` rather of ``char *``.
11151090
11161091
1117-
.. c:function:: PyObject* PyUnicode_EncodeUTF8(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
1118-
1119-
Encode the :c:type:`Py_UNICODE` buffer *s* of the given *size* using UTF-8 and
1120-
return a Python bytes object. Return ``NULL`` if an exception was raised by
1121-
the codec.
1122-
1123-
.. deprecated-removed:: 3.3 3.11
1124-
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
1125-
:c:func:`PyUnicode_AsUTF8String`, :c:func:`PyUnicode_AsUTF8AndSize` or
1126-
:c:func:`PyUnicode_AsEncodedString`.
1127-
1128-
11291092
UTF-32 Codecs
11301093
"""""""""""""
11311094
@@ -1176,29 +1139,6 @@ These are the UTF-32 codec APIs:
11761139
Return ``NULL`` if an exception was raised by the codec.
11771140
11781141
1179-
.. c:function:: PyObject* PyUnicode_EncodeUTF32(const Py_UNICODE *s, Py_ssize_t size, \
1180-
const char *errors, int byteorder)
1181-
1182-
Return a Python bytes object holding the UTF-32 encoded value of the Unicode
1183-
data in *s*. Output is written according to the following byte order::
1184-
1185-
byteorder == -1: little endian
1186-
byteorder == 0: native byte order (writes a BOM mark)
1187-
byteorder == 1: big endian
1188-
1189-
If byteorder is ``0``, the output string will always start with the Unicode BOM
1190-
mark (U+FEFF). In the other two modes, no BOM mark is prepended.
1191-
1192-
If ``Py_UNICODE_WIDE`` is not defined, surrogate pairs will be output
1193-
as a single code point.
1194-
1195-
Return ``NULL`` if an exception was raised by the codec.
1196-
1197-
.. deprecated-removed:: 3.3 3.11
1198-
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
1199-
:c:func:`PyUnicode_AsUTF32String` or :c:func:`PyUnicode_AsEncodedString`.
1200-
1201-
12021142
UTF-16 Codecs
12031143
"""""""""""""
12041144
@@ -1250,30 +1190,6 @@ These are the UTF-16 codec APIs:
12501190
Return ``NULL`` if an exception was raised by the codec.
12511191
12521192
1253-
.. c:function:: PyObject* PyUnicode_EncodeUTF16(const Py_UNICODE *s, Py_ssize_t size, \
1254-
const char *errors, int byteorder)
1255-
1256-
Return a Python bytes object holding the UTF-16 encoded value of the Unicode
1257-
data in *s*. Output is written according to the following byte order::
1258-
1259-
byteorder == -1: little endian
1260-
byteorder == 0: native byte order (writes a BOM mark)
1261-
byteorder == 1: big endian
1262-
1263-
If byteorder is ``0``, the output string will always start with the Unicode BOM
1264-
mark (U+FEFF). In the other two modes, no BOM mark is prepended.
1265-
1266-
If ``Py_UNICODE_WIDE`` is defined, a single :c:type:`Py_UNICODE` value may get
1267-
represented as a surrogate pair. If it is not defined, each :c:type:`Py_UNICODE`
1268-
values is interpreted as a UCS-2 character.
1269-
1270-
Return ``NULL`` if an exception was raised by the codec.
1271-
1272-
.. deprecated-removed:: 3.3 3.11
1273-
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
1274-
:c:func:`PyUnicode_AsUTF16String` or :c:func:`PyUnicode_AsEncodedString`.
1275-
1276-
12771193
UTF-7 Codecs
12781194
""""""""""""
12791195
@@ -1295,23 +1211,6 @@ These are the UTF-7 codec APIs:
12951211
bytes that have been decoded will be stored in *consumed*.
12961212
12971213
1298-
.. c:function:: PyObject* PyUnicode_EncodeUTF7(const Py_UNICODE *s, Py_ssize_t size, \
1299-
int base64SetO, int base64WhiteSpace, const char *errors)
1300-
1301-
Encode the :c:type:`Py_UNICODE` buffer of the given size using UTF-7 and
1302-
return a Python bytes object. Return ``NULL`` if an exception was raised by
1303-
the codec.
1304-
1305-
If *base64SetO* is nonzero, "Set O" (punctuation that has no otherwise
1306-
special meaning) will be encoded in base-64. If *base64WhiteSpace* is
1307-
nonzero, whitespace will be encoded in base-64. Both are set to zero for the
1308-
Python "utf-7" codec.
1309-
1310-
.. deprecated-removed:: 3.3 3.11
1311-
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
1312-
:c:func:`PyUnicode_AsEncodedString`.
1313-
1314-
13151214
Unicode-Escape Codecs
13161215
"""""""""""""""""""""
13171216
@@ -1332,16 +1231,6 @@ These are the "Unicode Escape" codec APIs:
13321231
raised by the codec.
13331232
13341233
1335-
.. c:function:: PyObject* PyUnicode_EncodeUnicodeEscape(const Py_UNICODE *s, Py_ssize_t size)
1336-
1337-
Encode the :c:type:`Py_UNICODE` buffer of the given *size* using Unicode-Escape and
1338-
return a bytes object. Return ``NULL`` if an exception was raised by the codec.
1339-
1340-
.. deprecated-removed:: 3.3 3.11
1341-
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
1342-
:c:func:`PyUnicode_AsUnicodeEscapeString`.
1343-
1344-
13451234
Raw-Unicode-Escape Codecs
13461235
"""""""""""""""""""""""""
13471236
@@ -1362,18 +1251,6 @@ These are the "Raw Unicode Escape" codec APIs:
13621251
was raised by the codec.
13631252
13641253
1365-
.. c:function:: PyObject* PyUnicode_EncodeRawUnicodeEscape(const Py_UNICODE *s, \
1366-
Py_ssize_t size)
1367-
1368-
Encode the :c:type:`Py_UNICODE` buffer of the given *size* using Raw-Unicode-Escape
1369-
and return a bytes object. Return ``NULL`` if an exception was raised by the codec.
1370-
1371-
.. deprecated-removed:: 3.3 3.11
1372-
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
1373-
:c:func:`PyUnicode_AsRawUnicodeEscapeString` or
1374-
:c:func:`PyUnicode_AsEncodedString`.
1375-
1376-
13771254
Latin-1 Codecs
13781255
""""""""""""""
13791256
@@ -1394,18 +1271,6 @@ ordinals and only these are accepted by the codecs during encoding.
13941271
raised by the codec.
13951272
13961273
1397-
.. c:function:: PyObject* PyUnicode_EncodeLatin1(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
1398-
1399-
Encode the :c:type:`Py_UNICODE` buffer of the given *size* using Latin-1 and
1400-
return a Python bytes object. Return ``NULL`` if an exception was raised by
1401-
the codec.
1402-
1403-
.. deprecated-removed:: 3.3 3.11
1404-
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
1405-
:c:func:`PyUnicode_AsLatin1String` or
1406-
:c:func:`PyUnicode_AsEncodedString`.
1407-
1408-
14091274
ASCII Codecs
14101275
""""""""""""
14111276
@@ -1426,18 +1291,6 @@ codes generate errors.
14261291
raised by the codec.
14271292
14281293
1429-
.. c:function:: PyObject* PyUnicode_EncodeASCII(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
1430-
1431-
Encode the :c:type:`Py_UNICODE` buffer of the given *size* using ASCII and
1432-
return a Python bytes object. Return ``NULL`` if an exception was raised by
1433-
the codec.
1434-
1435-
.. deprecated-removed:: 3.3 3.11
1436-
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
1437-
:c:func:`PyUnicode_AsASCIIString` or
1438-
:c:func:`PyUnicode_AsEncodedString`.
1439-
1440-
14411294
Character Map Codecs
14421295
""""""""""""""""""""
14431296
@@ -1477,19 +1330,6 @@ These are the mapping codec APIs:
14771330
``None`` are treated as "undefined mapping" and cause an error.
14781331
14791332
1480-
.. c:function:: PyObject* PyUnicode_EncodeCharmap(const Py_UNICODE *s, Py_ssize_t size, \
1481-
PyObject *mapping, const char *errors)
1482-
1483-
Encode the :c:type:`Py_UNICODE` buffer of the given *size* using the given
1484-
*mapping* object and return the result as a bytes object. Return ``NULL`` if
1485-
an exception was raised by the codec.
1486-
1487-
.. deprecated-removed:: 3.3 3.11
1488-
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
1489-
:c:func:`PyUnicode_AsCharmapString` or
1490-
:c:func:`PyUnicode_AsEncodedString`.
1491-
1492-
14931333
The following codec API is special in that maps Unicode to Unicode.
14941334
14951335
.. c:function:: PyObject* PyUnicode_Translate(PyObject *str, PyObject *table, const char *errors)
@@ -1509,19 +1349,6 @@ The following codec API is special in that maps Unicode to Unicode.
15091349
use the default error handling.
15101350
15111351
1512-
.. c:function:: PyObject* PyUnicode_TranslateCharmap(const Py_UNICODE *s, Py_ssize_t size, \
1513-
PyObject *mapping, const char *errors)
1514-
1515-
Translate a :c:type:`Py_UNICODE` buffer of the given *size* by applying a
1516-
character *mapping* table to it and return the resulting Unicode object.
1517-
Return ``NULL`` when an exception was raised by the codec.
1518-
1519-
.. deprecated-removed:: 3.3 3.11
1520-
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
1521-
:c:func:`PyUnicode_Translate`. or :ref:`generic codec based API
1522-
<codec-registry>`
1523-
1524-
15251352
MBCS codecs for Windows
15261353
"""""""""""""""""""""""
15271354
@@ -1561,18 +1388,6 @@ the user settings on the machine running the codec.
15611388
.. versionadded:: 3.3
15621389
15631390
1564-
.. c:function:: PyObject* PyUnicode_EncodeMBCS(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
1565-
1566-
Encode the :c:type:`Py_UNICODE` buffer of the given *size* using MBCS and return
1567-
a Python bytes object. Return ``NULL`` if an exception was raised by the
1568-
codec.
1569-
1570-
.. deprecated-removed:: 3.3 4.0
1571-
Part of the old-style :c:type:`Py_UNICODE` API; please migrate to using
1572-
:c:func:`PyUnicode_AsMBCSString`, :c:func:`PyUnicode_EncodeCodePage` or
1573-
:c:func:`PyUnicode_AsEncodedString`.
1574-
1575-
15761391
Methods & Slots
15771392
"""""""""""""""
15781393

0 commit comments

Comments
 (0)