Skip to content

Commit dc98a54

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 713ba03 commit dc98a54

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
@@ -635,11 +635,21 @@ The following functions are used to create and modify Unicode exceptions from C.
635635
*object*, *length*, *start*, *end* and *reason*. *encoding* and *reason* are
636636
UTF-8 encoded strings.
637637
638+
.. deprecated:: 3.3 3.11
639+
640+
``Py_UNICODE`` is deprecated since Python 3.3. Please migrate to
641+
``PyObject_CallFunction(PyExc_UnicodeEncodeError, "sOnns", ...)``.
642+
638643
.. c:function:: PyObject* PyUnicodeTranslateError_Create(const Py_UNICODE *object, Py_ssize_t length, Py_ssize_t start, Py_ssize_t end, const char *reason)
639644
640645
Create a :class:`UnicodeTranslateError` object with the attributes *object*,
641646
*length*, *start*, *end* and *reason*. *reason* is a UTF-8 encoded string.
642647
648+
.. deprecated:: 3.3 3.11
649+
650+
``Py_UNICODE`` is deprecated since Python 3.3. Please migrate to
651+
``PyObject_CallFunction(PyExc_UnicodeTranslateError, "Onns", ...)``.
652+
643653
.. c:function:: PyObject* PyUnicodeDecodeError_GetEncoding(PyObject *exc)
644654
PyObject* PyUnicodeEncodeError_GetEncoding(PyObject *exc)
645655

Include/cpython/pyerrors.h

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

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

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

0 commit comments

Comments
 (0)