Skip to content

Commit 4a4b9ff

Browse files
committed
Use PyBytesWriter_FinishWithPointer()
1 parent 9b5deeb commit 4a4b9ff

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

Objects/unicodeobject.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6221,14 +6221,13 @@ _PyUnicode_EncodeUTF32(PyObject *str,
62216221
Py_CLEAR(rep);
62226222
}
62236223

6224+
Py_XDECREF(errorHandler);
6225+
Py_XDECREF(exc);
6226+
62246227
/* Cut back to size actually needed. This is necessary for, for example,
62256228
encoding of a string containing isolated surrogates and the 'ignore'
62266229
handler is used. */
6227-
nsize = (unsigned char*) out - (unsigned char*) PyBytesWriter_GetData(writer);
6228-
PyObject *bytes = PyBytesWriter_FinishWithSize(writer, nsize);
6229-
Py_XDECREF(errorHandler);
6230-
Py_XDECREF(exc);
6231-
return bytes;
6230+
return PyBytesWriter_FinishWithPointer(writer, out);
62326231

62336232
error:
62346233
Py_XDECREF(rep);

0 commit comments

Comments
 (0)