From a049443fab2442fff090470f8a4ec7a7c79c83ff Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 3 Oct 2012 23:03:46 +0200 Subject: PyUnicode_Format(): disable overallocation when we are writing the last part of the output string --- Objects/unicodeobject.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 09067e9..53f0fb5 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -13583,8 +13583,10 @@ PyUnicode_Format(PyObject *format, PyObject *args) fmtpos++; fmtcnt--; } - if (fmtcnt < 0) + if (fmtcnt < 0) { fmtpos--; + writer.overallocate = 0; + } sublen = fmtpos - nonfmtpos; maxchar = _PyUnicode_FindMaxChar(uformat, nonfmtpos, nonfmtpos + sublen); -- cgit v0.12