mirror of
https://github.com/python/cpython.git
synced 2025-11-03 07:01:21 +00:00
gh-125196: PyUnicodeWriter_Discard(NULL) does nothing (#125222)
This commit is contained in:
parent
9ad55e85d7
commit
1b2a5485f9
3 changed files with 6 additions and 3 deletions
|
|
@ -1600,6 +1600,8 @@ object.
|
||||||
|
|
||||||
Discard the internal Unicode buffer and destroy the writer instance.
|
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)
|
.. c:function:: int PyUnicodeWriter_WriteChar(PyUnicodeWriter *writer, Py_UCS4 ch)
|
||||||
|
|
||||||
Write the single Unicode character *ch* into *writer*.
|
Write the single Unicode character *ch* into *writer*.
|
||||||
|
|
|
||||||
|
|
@ -563,9 +563,7 @@ list_repr_impl(PyListObject *v)
|
||||||
return PyUnicodeWriter_Finish(writer);
|
return PyUnicodeWriter_Finish(writer);
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if (writer != NULL) {
|
PyUnicodeWriter_Discard(writer);
|
||||||
PyUnicodeWriter_Discard(writer);
|
|
||||||
}
|
|
||||||
Py_ReprLeave((PyObject *)v);
|
Py_ReprLeave((PyObject *)v);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13455,6 +13455,9 @@ PyUnicodeWriter_Create(Py_ssize_t length)
|
||||||
|
|
||||||
void PyUnicodeWriter_Discard(PyUnicodeWriter *writer)
|
void PyUnicodeWriter_Discard(PyUnicodeWriter *writer)
|
||||||
{
|
{
|
||||||
|
if (writer == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
_PyUnicodeWriter_Dealloc((_PyUnicodeWriter*)writer);
|
_PyUnicodeWriter_Dealloc((_PyUnicodeWriter*)writer);
|
||||||
PyMem_Free(writer);
|
PyMem_Free(writer);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue