New submission from STINNER Victor <victor.stin...@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 <rep...@bugs.python.org>
<http://bugs.python.org/issue13526>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to