Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Doc/c-api/unicode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1600,6 +1600,8 @@ object.

Discard the internal Unicode buffer and destroy the writer instance.

If *writer* is ``NULL``, no operation is performed.

.. c:function:: int PyUnicodeWriter_WriteChar(PyUnicodeWriter *writer, Py_UCS4 ch)

Write the single Unicode character *ch* into *writer*.
Expand Down
4 changes: 1 addition & 3 deletions Objects/listobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,9 +563,7 @@ list_repr_impl(PyListObject *v)
return PyUnicodeWriter_Finish(writer);

error:
if (writer != NULL) {
PyUnicodeWriter_Discard(writer);
}
PyUnicodeWriter_Discard(writer);
Py_ReprLeave((PyObject *)v);
return NULL;
}
Expand Down
3 changes: 3 additions & 0 deletions Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -13455,6 +13455,9 @@ PyUnicodeWriter_Create(Py_ssize_t length)

void PyUnicodeWriter_Discard(PyUnicodeWriter *writer)
{
if (writer == NULL) {
return;
}
_PyUnicodeWriter_Dealloc((_PyUnicodeWriter*)writer);
PyMem_Free(writer);
}
Expand Down
Loading