diff -r c14a2d2a3b19 Doc/whatsnew/3.6.rst --- a/Doc/whatsnew/3.6.rst Tue Oct 25 10:37:55 2016 +0300 +++ b/Doc/whatsnew/3.6.rst Tue Oct 25 11:20:30 2016 +0300 @@ -1230,7 +1230,10 @@ Deprecated Python modules, functions and Deprecated functions and types of the C API ------------------------------------------- -* None yet. +* Undocumented functions :c:func:`PyUnicode_AsEncodedObject`, + :c:func:`PyUnicode_AsDecodedObject`, :c:func:`PyUnicode_AsEncodedUnicode` + and :c:func:`PyUnicode_AsDecodedUnicode` are deprecated now. + Use :ref:`generic codec based API ` instead. Deprecated features diff -r c14a2d2a3b19 Misc/NEWS --- a/Misc/NEWS Tue Oct 25 10:37:55 2016 +0300 +++ b/Misc/NEWS Tue Oct 25 11:20:30 2016 +0300 @@ -68,6 +68,13 @@ Library threadpool executor. Initial patch by Hans Lawrenz. +C API +----- + +- Issue #28426: Undocumented functions PyUnicode_AsEncodedObject(), + PyUnicode_AsDecodedObject(), PyUnicode_AsDecodedUnicode() and + PyUnicode_AsEncodedUnicode() are deprecated now. + Build ----- diff -r c14a2d2a3b19 Objects/unicodeobject.c --- a/Objects/unicodeobject.c Tue Oct 25 10:37:55 2016 +0300 +++ b/Objects/unicodeobject.c Tue Oct 25 11:20:30 2016 +0300 @@ -3241,6 +3241,11 @@ PyUnicode_AsDecodedObject(PyObject *unic return NULL; } + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "PyUnicode_AsDecodedObject() is deprecated; " + "use PyCodec_Decode() to decode from str", 1) < 0) + return NULL; + if (encoding == NULL) encoding = PyUnicode_GetDefaultEncoding(); @@ -3260,6 +3265,11 @@ PyUnicode_AsDecodedUnicode(PyObject *uni goto onError; } + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "PyUnicode_AsDecodedUnicode() is deprecated; " + "use PyCodec_Decode() to decode from str to str", 1) < 0) + return NULL; + if (encoding == NULL) encoding = PyUnicode_GetDefaultEncoding(); @@ -3310,6 +3320,12 @@ PyUnicode_AsEncodedObject(PyObject *unic goto onError; } + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "PyUnicode_AsEncodedObject() is deprecated; " + "use PyUnicode_AsEncodedString() to encode from str to bytes " + "or PyCodec_Encode() for generic encoding", 1) < 0) + return NULL; + if (encoding == NULL) encoding = PyUnicode_GetDefaultEncoding(); @@ -3635,6 +3651,11 @@ PyUnicode_AsEncodedUnicode(PyObject *uni goto onError; } + if (PyErr_WarnEx(PyExc_DeprecationWarning, + "PyUnicode_AsEncodedUnicode() is deprecated; " + "use PyCodec_Encode() to encode from str to str", 1) < 0) + return NULL; + if (encoding == NULL) encoding = PyUnicode_GetDefaultEncoding();