[Python-Dev] Chose a name for a "get unicode as wide character, borrowed reference" function

Victor Stinner victor.stinner at haypocalc.com
Mon Nov 21 16:53:10 CET 2011


Le Lundi 21 Novembre 2011 16:04:06 Antoine Pitrou a écrit :
> On Mon, 21 Nov 2011 12:53:17 +0100
> 
> Victor Stinner <victor.stinner at haypocalc.com> wrote:
> > I would like to add a new PyUnicode_AsWideChar() function which would
> > return the borrowed reference, exactly as PyUnicode_AsUnicode(). The
> > problem is that "PyUnicode_AsWideChar" already exists in Python 3.2, as
> > PyUnicode_AsWideCharString.
> 
> This is not very clear. You are proposing to add a function which
> already exists, except that you have to free the pointer yourself?
> I don't think that's a good idea, the API is already large enough.

I want to rename PyUnicode_AsUnicode() and change its result type (Py_UNICODE* 
=> wchar_t*). The result will be a "borrowed reference", ie. you don't have to 
free the memory, it will be done when the Unicode string will be destroyed (by 
Py_DECREF).

The problem is that Py_UNICODE type is now deprecated.

Victor


More information about the Python-Dev mailing list