Skip to content

Commit

Permalink
bpo-41098: Doc: Add missing deprecated directives (pythonGH-21162)
Browse files Browse the repository at this point in the history
PyUnicodeEncodeError_Create has been deprecated with
`Py_DEPRECATED` macro. But it was not documented.
  • Loading branch information
methane authored and Seth Sims committed Oct 18, 2020
1 parent 2bc48da commit 075b582
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 10 additions & 0 deletions Doc/c-api/exceptions.rst
Expand Up @@ -637,11 +637,21 @@ 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.
.. 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
10 changes: 8 additions & 2 deletions Include/cpython/pyerrors.h
Expand Up @@ -145,7 +145,10 @@ PyAPI_FUNC(PyObject *) PyErr_ProgramTextObject(
PyObject *filename,
int lineno);

/* Create a UnicodeEncodeError object */
/* Create a UnicodeEncodeError object.
*
* TODO: This API will be removed in Python 3.11.
*/
Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_Create(
const char *encoding, /* UTF-8 encoded string */
const Py_UNICODE *object,
Expand All @@ -155,7 +158,10 @@ Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_Create(
const char *reason /* UTF-8 encoded string */
);

/* Create a UnicodeTranslateError object */
/* Create a UnicodeTranslateError object.
*
* TODO: This API will be removed in Python 3.11.
*/
Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create(
const Py_UNICODE *object,
Py_ssize_t length,
Expand Down

0 comments on commit 075b582

Please sign in to comment.