[New-bugs-announce] [issue13526] Deprecate the old Unicode API

STINNER Victor report at bugs.python.org
Sat Dec 3 20:10:49 CET 2011


New submission from STINNER Victor <victor.stinner at haypocalc.com>:

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.

----------
components: Unicode
files: unicode_warn_deprecate.patch
keywords: patch
messages: 148818
nosy: ezio.melotti, haypo, loewis
priority: normal
severity: normal
status: open
title: Deprecate the old Unicode API
versions: Python 3.3
Added file: http://bugs.python.org/file23845/unicode_warn_deprecate.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13526>
_______________________________________


More information about the New-bugs-announce mailing list