[New-bugs-announce] [issue22271] Deprecate PyUnicode_AsUnicode(): emit a DeprecationWarning

STINNER Victor report at bugs.python.org
Mon Aug 25 03:41:16 CEST 2014

New submission from STINNER Victor:

With the PEP 393 implemented in Python 3.3, PyUnicode_AsUnicode() and all similar functions have to convert the compact string to a heavy wchar_t* string (UCS-4 on Linux: 4 bytes per character, UTF-16 on Windows: 2 or 4 bytes per character) which is stored in the string. The heavy "Py_UNICODE*" storage is kept until the string is destroyed, which may only occur at Python exit.

To reduce the memory footprint, it would be nice to promote the usage of the PEP 393 and start to emit a DeprecationWarning warning. The Py_UNICODE type and all related functions are already deprecated in the documentation.

The deprecate PyUnicode_AsUnicode(), we should stop using it in Python itself. For example, PyUnicode_AsWideCharString() can be used to encode filenames on Windows, it doesn't store the encoded string in the Python object. See for example path_converter() in posixmodule.c.

messages: 225860
nosy: haypo, loewis
priority: normal
severity: normal
status: open
title: Deprecate PyUnicode_AsUnicode(): emit a DeprecationWarning
versions: Python 3.5

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list