Skip to content

Commit 46e19b6

Browse files
authored
bpo-41098: Doc: Add missing deprecated directives (GH-21162)
PyUnicodeEncodeError_Create has been deprecated with `Py_DEPRECATED` macro. But it was not documented.
1 parent 5463635 commit 46e19b6

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
@@ -145,7 +145,10 @@ PyAPI_FUNC(PyObject *) PyErr_ProgramTextObject(
145145
PyObject *filename,
146146
int lineno);
147147

148-
/* Create a UnicodeEncodeError object */
148+
/* Create a UnicodeEncodeError object.
149+
*
150+
* TODO: This API will be removed in Python 3.11.
151+
*/
149152
Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_Create(
150153
const char *encoding, /* UTF-8 encoded string */
151154
const Py_UNICODE *object,
@@ -155,7 +158,10 @@ Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_Create(
155158
const char *reason /* UTF-8 encoded string */
156159
);
157160

158-
/* Create a UnicodeTranslateError object */
161+
/* Create a UnicodeTranslateError object.
162+
*
163+
* TODO: This API will be removed in Python 3.11.
164+
*/
159165
Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create(
160166
const Py_UNICODE *object,
161167
Py_ssize_t length,

0 commit comments

Comments
 (0)