Skip to content

Commit

Permalink
Rename PyUnicode_FreeExport() to PyUnicode_ReleaseExport()
Browse files Browse the repository at this point in the history
  • Loading branch information
vstinner committed Jun 11, 2024
1 parent 4d77192 commit 076985d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
11 changes: 7 additions & 4 deletions Include/unicodeobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion Modules/_testlimitedcapi/unicode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
3 changes: 2 additions & 1 deletion Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 076985d

Please sign in to comment.