[Python-checkins] cpython: PyUnicode_Format(): disable overallocation when we are writing the last part

victor.stinner python-checkins at python.org
Wed Oct 3 23:14:23 CEST 2012


http://hg.python.org/cpython/rev/93757fb49837
changeset:   79436:93757fb49837
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Wed Oct 03 23:03:46 2012 +0200
summary:
  PyUnicode_Format(): disable overallocation when we are writing the last part
of the output string

files:
  Objects/unicodeobject.c |  4 +++-
  1 files changed, 3 insertions(+), 1 deletions(-)


diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -13583,8 +13583,10 @@
                 fmtpos++;
                 fmtcnt--;
             }
-            if (fmtcnt < 0)
+            if (fmtcnt < 0) {
                 fmtpos--;
+                writer.overallocate = 0;
+            }
             sublen = fmtpos - nonfmtpos;
             maxchar = _PyUnicode_FindMaxChar(uformat,
                                              nonfmtpos, nonfmtpos + sublen);

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list