[issue39087] [C API] No efficient C API to get UTF-8 string from unicode object.

STINNER Victor report at bugs.python.org
Thu Dec 19 04:46:19 EST 2019


STINNER Victor <vstinner at python.org> added the comment:

> The returned object is the owner of the *utf8*.  You need to Py_DECREF() it after
> you finished to using the *utf8*.  The owner may be not the unicode.

Would it be possible to use a "container" object like a Py_buffer? Is there a way to customize the code executed when a Py_buffer is "released"?

Py_buffer would be nice since it already has a pointer attribute (data) and a length attribute, and there is an API to "release" a Py_buffer. It can be marked as read-only, etc.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39087>
_______________________________________


More information about the Python-bugs-list mailing list