]> granicus.if.org Git - python/commitdiff
PyUnicode_Format(): disable overallocation when we are writing the last part
authorVictor Stinner <victor.stinner@gmail.com>
Wed, 3 Oct 2012 21:03:46 +0000 (23:03 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Wed, 3 Oct 2012 21:03:46 +0000 (23:03 +0200)
of the output string

Objects/unicodeobject.c

index 09067e919c46dd4f4bb7d4e6042ac7a55d858c39..53f0fb5a3f100395bc05af42406ae0de68b26486 100644 (file)
@@ -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);