Issue #19513: Disable overallocation of the PyUnicodeWriter before the last write
diff --git a/Objects/listobject.c b/Objects/listobject.c
index 50538e1..45666fd 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -387,6 +387,7 @@
         Py_DECREF(s);
     }
 
+    writer.overallocate = 0;
     if (_PyUnicodeWriter_WriteChar(&writer, ']') < 0)
         goto error;