From 4f293fd172ff458954f93032cbeeadd7a27f9198 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Fri, 26 Jun 2020 08:29:16 +0900 Subject: [PATCH 1/4] bpo-41098: Doc: Deprecate PyUnicodeEncodeError_Create PyUnicodeEncodeError_Create has been deprecated with `Py_DEPRECATED` macro. But it was not documented. --- Doc/c-api/exceptions.rst | 6 ++++++ Include/cpython/pyerrors.h | 5 ++++- .../Documentation/2020-06-26-08-27-34.bpo-41098.u3-eRb.rst | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Documentation/2020-06-26-08-27-34.bpo-41098.u3-eRb.rst diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst index e7805ba143c584..c0f27183f5dd0c 100644 --- a/Doc/c-api/exceptions.rst +++ b/Doc/c-api/exceptions.rst @@ -637,6 +637,12 @@ 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 + + ``Py_UNICODE`` is deprecated since Python 3.3. This API will be removed + in Python 3.11. 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*, diff --git a/Include/cpython/pyerrors.h b/Include/cpython/pyerrors.h index 3f347dc2e2d62b..6cd3665288430c 100644 --- a/Include/cpython/pyerrors.h +++ b/Include/cpython/pyerrors.h @@ -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, diff --git a/Misc/NEWS.d/next/Documentation/2020-06-26-08-27-34.bpo-41098.u3-eRb.rst b/Misc/NEWS.d/next/Documentation/2020-06-26-08-27-34.bpo-41098.u3-eRb.rst new file mode 100644 index 00000000000000..259e411e79ff3b --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2020-06-26-08-27-34.bpo-41098.u3-eRb.rst @@ -0,0 +1 @@ +Added missing ``deprecated`` directive for ``PyUnicodeEncodeError_Create``. From 42144718b224c34d686ef0478dcf6b7d62036d91 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Fri, 26 Jun 2020 10:50:24 +0900 Subject: [PATCH 2/4] Delete 2020-06-26-08-27-34.bpo-41098.u3-eRb.rst --- .../next/Documentation/2020-06-26-08-27-34.bpo-41098.u3-eRb.rst | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Misc/NEWS.d/next/Documentation/2020-06-26-08-27-34.bpo-41098.u3-eRb.rst diff --git a/Misc/NEWS.d/next/Documentation/2020-06-26-08-27-34.bpo-41098.u3-eRb.rst b/Misc/NEWS.d/next/Documentation/2020-06-26-08-27-34.bpo-41098.u3-eRb.rst deleted file mode 100644 index 259e411e79ff3b..00000000000000 --- a/Misc/NEWS.d/next/Documentation/2020-06-26-08-27-34.bpo-41098.u3-eRb.rst +++ /dev/null @@ -1 +0,0 @@ -Added missing ``deprecated`` directive for ``PyUnicodeEncodeError_Create``. From 4410580d92157f30655e4c6371510a106f07a004 Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Fri, 26 Jun 2020 10:55:16 +0900 Subject: [PATCH 3/4] Deprecate PyUnicodeTranslateError_Create too --- Doc/c-api/exceptions.rst | 6 ++++++ Include/cpython/pyerrors.h | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst index c0f27183f5dd0c..a3105914af0e85 100644 --- a/Doc/c-api/exceptions.rst +++ b/Doc/c-api/exceptions.rst @@ -648,6 +648,12 @@ The following functions are used to create and modify Unicode exceptions from C. Create a :class:`UnicodeTranslateError` object with the attributes *object*, *length*, *start*, *end* and *reason*. *reason* is a UTF-8 encoded string. + .. deprecated:: 3.3 + + ``Py_UNICODE`` is deprecated since Python 3.3. This API will be removed + in Python 3.11. Please migrate to + ``PyObject_CallFunction(PyExc_UnicodeTranslateError, "Onns", ...)``. + .. c:function:: PyObject* PyUnicodeDecodeError_GetEncoding(PyObject *exc) PyObject* PyUnicodeEncodeError_GetEncoding(PyObject *exc) diff --git a/Include/cpython/pyerrors.h b/Include/cpython/pyerrors.h index 6cd3665288430c..c2500d927bf7f0 100644 --- a/Include/cpython/pyerrors.h +++ b/Include/cpython/pyerrors.h @@ -145,7 +145,7 @@ 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. */ @@ -158,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, From a44139425d660f8a545ffa76e2dee354e62b8d28 Mon Sep 17 00:00:00 2001 From: INADA Naoki Date: Fri, 26 Jun 2020 21:07:12 +0900 Subject: [PATCH 4/4] set removal version --- Doc/c-api/exceptions.rst | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst index a3105914af0e85..b4722ff81979f4 100644 --- a/Doc/c-api/exceptions.rst +++ b/Doc/c-api/exceptions.rst @@ -637,10 +637,9 @@ 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 + .. deprecated:: 3.3 3.11 - ``Py_UNICODE`` is deprecated since Python 3.3. This API will be removed - in Python 3.11. Please migrate to + ``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) @@ -648,10 +647,9 @@ The following functions are used to create and modify Unicode exceptions from C. Create a :class:`UnicodeTranslateError` object with the attributes *object*, *length*, *start*, *end* and *reason*. *reason* is a UTF-8 encoded string. - .. deprecated:: 3.3 + .. deprecated:: 3.3 3.11 - ``Py_UNICODE`` is deprecated since Python 3.3. This API will be removed - in Python 3.11. Please migrate to + ``Py_UNICODE`` is deprecated since Python 3.3. Please migrate to ``PyObject_CallFunction(PyExc_UnicodeTranslateError, "Onns", ...)``. .. c:function:: PyObject* PyUnicodeDecodeError_GetEncoding(PyObject *exc)