diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h index c23849a0365982..e9ccb480ded2c7 100644 --- a/Include/unicodeobject.h +++ b/Include/unicodeobject.h @@ -254,21 +254,24 @@ PyAPI_FUNC(PyObject *) PyUnicode_InternFromString( #define PyUnicode_FORMAT_UCS4 0x08 #define PyUnicode_FORMAT_UTF8 0x10 -// Get the content of a string in its native format. -// - Return the content, set '*size' and '*native_format' on success. +// Get the content of a string in the requested format: +// - Return the content, set '*size' and '*format' on success. // - Set an exception and return NULL on error. +// +// The export must be released by PyUnicode_ReleaseExport(). PyAPI_FUNC(const void*) PyUnicode_Export( PyObject *unicode, unsigned int supported_formats, Py_ssize_t *size, unsigned int *format); -PyAPI_FUNC(void) PyUnicode_FreeExport( +// Release an export created by PyUnicode_Export(). +PyAPI_FUNC(void) PyUnicode_ReleaseExport( PyObject *unicode, const void* data, unsigned int format); -// Create a string object from a native format string. +// Create a string object from a string in the format 'format'. // - Return a reference to a new string object on success. // - Set an exception and return NULL on error. PyAPI_FUNC(PyObject*) PyUnicode_Import( diff --git a/Modules/_testlimitedcapi/unicode.c b/Modules/_testlimitedcapi/unicode.c index 360f432fd51a57..306612e726aaab 100644 --- a/Modules/_testlimitedcapi/unicode.c +++ b/Modules/_testlimitedcapi/unicode.c @@ -1856,7 +1856,7 @@ unicode_export(PyObject *self, PyObject *args) } PyObject *res = Py_BuildValue("y#i", data, size, format); - PyUnicode_FreeExport(obj, data, format); + PyUnicode_ReleaseExport(obj, data, format); return res; } diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 020b0b3bacefd9..19ce47b0b8bfa8 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -2170,7 +2170,8 @@ PyUnicode_Export(PyObject *unicode, unsigned int supported_formats, } void -PyUnicode_FreeExport(PyObject *unicode, const void* data, unsigned int format) +PyUnicode_ReleaseExport(PyObject *unicode, const void* data, + unsigned int format) { switch (format) {