This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Deprecate the old Unicode API
Type: Stage:
Components: Unicode Versions: Python 3.3
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, ezio.melotti, georg.brandl, loewis, pitrou, vstinner
Priority: normal Keywords: patch

Created on 2011-12-03 19:10 by vstinner, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
unicode_warn_deprecate.patch vstinner, 2011-12-03 19:10 review
Messages (5)
msg148818 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-12-03 19:10
Attached patch modifies the following function to emit a DeprecationWarning:
 * PyUnicode_GET_SIZE() (and so PyUnicode_GET_DATA_SIZE())
 * PyUnicode_AS_UNICODE()
 * PyUnicode_AsUnicodeAndSize() (and so PyUnicode_AsUnicode())
 * PyUnicode_FromUnicode()

PyUnicode_GET_SIZE() macro is converted to a function.

The patch adds PyUnicode_AsWideCharAndSize() because PyUnicode_AsUnicodeAndSize() is deprecated and it is still useful to convert a Unicode string to wchar_t* without having to care of freeing the memory.

The patch changes tests to ignore DeprecationWarning.

--

"PyUnicode_AsWideCharAndSize" name is maybe confusing because "PyUnicode_AsWideChar" exists, whereas PyUnicode_AsWideChar() requires to free explicitly the memory.

--

PyUnicode_AsUnicodeAndSize() should maybe fail with an error if the string kind is not PyUnicode_WCHAR_KIND.

--

The CJK codecs should be modified to use the new Unicode API before applying this patch, or test_codecs (and other tests using CJK codecs) would fail with python -Werror.
msg148819 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-12-03 19:47
I'm not sure it is customary for C APIs to emit deprecation warnings.
msg148838 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2011-12-04 05:16
Quoting the PEP "While the Py_UNICODE representation and APIs are deprecated with this PEP, no removal of the respective APIs is scheduled. The APIs should remain available at least five years after the PEP is accepted"

I don't think there should be warnings.
msg148843 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2011-12-04 08:40
I agree with Benjamin.
msg148848 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2011-12-04 09:27
Closing this as rejected, for the reasons given.
History
Date User Action Args
2022-04-11 14:57:24adminsetgithub: 57735
2011-12-04 09:27:50loewissetstatus: open -> closed
resolution: rejected
messages: + msg148848
2011-12-04 08:40:06georg.brandlsetnosy: + georg.brandl
messages: + msg148843
2011-12-04 05:16:18benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg148838
2011-12-03 19:47:48pitrousetnosy: + pitrou
messages: + msg148819
2011-12-03 19:10:49vstinnercreate