Skip to content

Commit b2514c4

Browse files
bpo-41098: Doc: Add missing deprecated directives (GH-21162)
PyUnicodeEncodeError_Create has been deprecated with `Py_DEPRECATED` macro. But it was not documented. (cherry picked from commit 46e19b6) Co-authored-by: Inada Naoki <[email protected]>
1 parent fc354ca commit b2514c4

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

Doc/c-api/exceptions.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,11 +637,21 @@ The following functions are used to create and modify Unicode exceptions from C.
637637
*object*, *length*, *start*, *end* and *reason*. *encoding* and *reason* are
638638
UTF-8 encoded strings.
639639
640+
.. deprecated:: 3.3 3.11
641+
642+
``Py_UNICODE`` is deprecated since Python 3.3. Please migrate to
643+
``PyObject_CallFunction(PyExc_UnicodeEncodeError, "sOnns", ...)``.
644+
640645
.. c:function:: PyObject* PyUnicodeTranslateError_Create(const Py_UNICODE *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason)
641646
642647
Create a :class:`UnicodeTranslateError` object with the attributes *object*,
643648
*length*, *start*, *end* and *reason*. *reason* is a UTF-8 encoded string.
644649
650+
.. deprecated:: 3.3 3.11
651+
652+
``Py_UNICODE`` is deprecated since Python 3.3. Please migrate to
653+
``PyObject_CallFunction(PyExc_UnicodeTranslateError, "Onns", ...)``.
654+
645655
.. c:function:: PyObject* PyUnicodeDecodeError_GetEncoding(PyObject *exc)
646656
PyObject* PyUnicodeEncodeError_GetEncoding(PyObject *exc)
647657

Include/cpython/pyerrors.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,10 @@ PyAPI_FUNC(PyObject *) PyErr_ProgramTextObject(
149149
PyObject *filename,
150150
int lineno);
151151

152-
/* Create a UnicodeEncodeError object */
152+
/* Create a UnicodeEncodeError object.
153+
*
154+
* TODO: This API will be removed in Python 3.11.
155+
*/
153156
Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_Create(
154157
const char *encoding, /* UTF-8 encoded string */
155158
const Py_UNICODE *object,
@@ -159,7 +162,10 @@ Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_Create(
159162
const char *reason /* UTF-8 encoded string */
160163
);
161164

162-
/* Create a UnicodeTranslateError object */
165+
/* Create a UnicodeTranslateError object.
166+
*
167+
* TODO: This API will be removed in Python 3.11.
168+
*/
163169
Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create(
164170
const Py_UNICODE *object,
165171
Py_ssize_t length,

0 commit comments

Comments
 (0)