diff -r ad3d6010379b Objects/unicodeobject.c --- a/Objects/unicodeobject.c Mon Apr 30 01:39:57 2012 +0200 +++ b/Objects/unicodeobject.c Mon Apr 30 03:06:59 2012 +0200 @@ -13610,56 +13610,22 @@ formatchar(PyObject *v) return (Py_UCS4) -1; } -static int -repeat_accumulate(_PyAccu *acc, PyObject *obj, Py_ssize_t count) -{ - int r; - assert(count > 0); - assert(PyUnicode_Check(obj)); - if (count > 5) { - PyObject *repeated = unicode_repeat(obj, count); - if (repeated == NULL) - return -1; - r = _PyAccu_Accumulate(acc, repeated); - Py_DECREF(repeated); - return r; - } - else { - do { - if (_PyAccu_Accumulate(acc, obj)) - return -1; - } while (--count); - return 0; - } -} - PyObject * PyUnicode_Format(PyObject *format, PyObject *args) { - void *fmt; - int fmtkind; - PyObject *result; - int kind; - int r; - Py_ssize_t fmtcnt, fmtpos, arglen, argidx; + PyObject *result = NULL; + enum PyUnicode_Kind kind, fmtkind, reskind; + void *fmt, *resdata; + Py_ssize_t fmtcnt, fmtpos, arglen, argidx, fargidx; int args_owned = 0; PyObject *dict = NULL; PyObject *temp = NULL; PyObject *second = NULL; + PyObject *fargs = NULL; PyObject *uformat; - _PyAccu acc; - static PyObject *plus, *minus, *blank, *zero, *percent; - - if (!plus && !(plus = get_latin1_char('+'))) - return NULL; - if (!minus && !(minus = get_latin1_char('-'))) - return NULL; - if (!blank && !(blank = get_latin1_char(' '))) - return NULL; - if (!zero && !(zero = get_latin1_char('0'))) - return NULL; - if (!percent && !(percent = get_latin1_char('%'))) - return NULL; + Py_UCS4 maxchar, maxchar2; + Py_ssize_t respos; + int write; if (format == NULL || args == NULL) { PyErr_BadInternalCall(); @@ -13670,149 +13636,153 @@ PyUnicode_Format(PyObject *format, PyObj return NULL; if (PyUnicode_READY(uformat) == -1) Py_DECREF(uformat); - if (_PyAccu_Init(&acc)) - goto onError; + fmt = PyUnicode_DATA(uformat); fmtkind = PyUnicode_KIND(uformat); - fmtcnt = PyUnicode_GET_LENGTH(uformat); - fmtpos = 0; - - if (PyTuple_Check(args)) { - arglen = PyTuple_Size(args); - argidx = 0; - } - else { - arglen = -1; - argidx = -2; - } + if (Py_TYPE(args)->tp_as_mapping && !PyTuple_Check(args) && !PyUnicode_Check(args)) dict = args; - while (--fmtcnt >= 0) { - if (PyUnicode_READ(fmtkind, fmt, fmtpos) != '%') { - PyObject *nonfmt; - Py_ssize_t nonfmtpos; - nonfmtpos = fmtpos++; - while (fmtcnt >= 0 && - PyUnicode_READ(fmtkind, fmt, fmtpos) != '%') { + fargs = PyList_New(0); + if (fargs == NULL) + goto onError; + fargidx = 0; + respos = 0; + maxchar = 127; + /* set resdata and reskind to dummy values to avoid compiler warnings */ + resdata = NULL; + reskind = PyUnicode_1BYTE_KIND; + + /* Format the string in two steps: + 1) write=0: compute the maximum character and the length of + the output string + 2) write=1: write characters into the output string */ + for (write=0; write<2; write++) { + if (write) { + /* Step 2: allocate the output string */ + result = PyUnicode_New(respos, maxchar); + if (result == NULL) + goto onError; + respos = 0; + reskind = PyUnicode_KIND(result); + resdata = PyUnicode_DATA(result); + } + + fmtcnt = PyUnicode_GET_LENGTH(uformat); + fmtpos = 0; + + if (PyTuple_Check(args)) { + arglen = PyTuple_Size(args); + argidx = 0; + } + else { + arglen = -1; + argidx = -2; + } + + while (--fmtcnt >= 0) { + if (PyUnicode_READ(fmtkind, fmt, fmtpos) != '%') { + Py_ssize_t nonfmtpos, sublen; + nonfmtpos = fmtpos++; + while (fmtcnt >= 0 && + PyUnicode_READ(fmtkind, fmt, fmtpos) != '%') { + fmtpos++; + fmtcnt--; + } + sublen = fmtpos - nonfmtpos; + if (fmtcnt < 0) + sublen--; + if (write) { + copy_characters(result, respos, + uformat, nonfmtpos, sublen); + } + else { + maxchar2 = _PyUnicode_FindMaxChar(uformat, nonfmtpos, + nonfmtpos+sublen); + maxchar |= maxchar2; + } + respos += sublen; + } + else { + /* Got a format specifier */ + int flags = 0; + Py_ssize_t width = -1; + int prec = -1; + Py_UCS4 c = '\0'; + Py_UCS4 fill, sign; + PyObject *v = NULL; + void *pbuf = NULL; + Py_ssize_t pindex, len; + Py_UCS4 signchar; + fmtpos++; - fmtcnt--; - } - nonfmt = PyUnicode_Substring(uformat, nonfmtpos, fmtpos); - if (nonfmt == NULL) - goto onError; - r = _PyAccu_Accumulate(&acc, nonfmt); - Py_DECREF(nonfmt); - if (r) - goto onError; - } - else { - /* Got a format specifier */ - int flags = 0; - Py_ssize_t width = -1; - int prec = -1; - Py_UCS4 c = '\0'; - Py_UCS4 fill, sign; - int isnumok; - PyObject *v = NULL; - void *pbuf = NULL; - Py_ssize_t pindex, len; - PyObject *signobj = NULL, *fillobj = NULL; - - fmtpos++; - if (PyUnicode_READ(fmtkind, fmt, fmtpos) == '(') { - Py_ssize_t keystart; - Py_ssize_t keylen; - PyObject *key; - int pcount = 1; - - if (dict == NULL) { - PyErr_SetString(PyExc_TypeError, - "format requires a mapping"); - goto onError; - } - ++fmtpos; - --fmtcnt; - keystart = fmtpos; - /* Skip over balanced parentheses */ - while (pcount > 0 && --fmtcnt >= 0) { - if (PyUnicode_READ(fmtkind, fmt, fmtpos) == ')') - --pcount; - else if (PyUnicode_READ(fmtkind, fmt, fmtpos) == '(') - ++pcount; - fmtpos++; - } - keylen = fmtpos - keystart - 1; - if (fmtcnt < 0 || pcount > 0) { - PyErr_SetString(PyExc_ValueError, - "incomplete format key"); - goto onError; - } - key = PyUnicode_Substring(uformat, - keystart, keystart + keylen); - if (key == NULL) - goto onError; - if (args_owned) { - Py_DECREF(args); - args_owned = 0; - } - args = PyObject_GetItem(dict, key); - Py_DECREF(key); - if (args == NULL) { - goto onError; - } - args_owned = 1; - arglen = -1; - argidx = -2; - } - while (--fmtcnt >= 0) { - switch (c = PyUnicode_READ(fmtkind, fmt, fmtpos++)) { - case '-': flags |= F_LJUST; continue; - case '+': flags |= F_SIGN; continue; - case ' ': flags |= F_BLANK; continue; - case '#': flags |= F_ALT; continue; - case '0': flags |= F_ZERO; continue; - } - break; - } - if (c == '*') { - v = getnextarg(args, arglen, &argidx); - if (v == NULL) - goto onError; - if (!PyLong_Check(v)) { - PyErr_SetString(PyExc_TypeError, - "* wants int"); - goto onError; - } - width = PyLong_AsLong(v); - if (width == -1 && PyErr_Occurred()) - goto onError; - if (width < 0) { - flags |= F_LJUST; - width = -width; - } - if (--fmtcnt >= 0) - c = PyUnicode_READ(fmtkind, fmt, fmtpos++); - } - else if (c >= '0' && c <= '9') { - width = c - '0'; + if (PyUnicode_READ(fmtkind, fmt, fmtpos) == '(') { + Py_ssize_t keystart; + Py_ssize_t keylen; + PyObject *key; + int pcount = 1; + + if (dict == NULL) { + PyErr_SetString(PyExc_TypeError, + "format requires a mapping"); + goto onError; + } + ++fmtpos; + --fmtcnt; + keystart = fmtpos; + /* Skip over balanced parentheses */ + while (pcount > 0 && --fmtcnt >= 0) { + c = PyUnicode_READ(fmtkind, fmt, fmtpos); + if (c == ')') + --pcount; + else if (c == '(') + ++pcount; + fmtpos++; + } + if (args_owned) { + Py_DECREF(args); + args_owned = 0; + } + if (!write) { + keylen = fmtpos - keystart - 1; + if (fmtcnt < 0 || pcount > 0) { + PyErr_SetString(PyExc_ValueError, + "incomplete format key"); + goto onError; + } + key = PyUnicode_Substring(uformat, + keystart, keystart + keylen); + if (key == NULL) + goto onError; + args = PyObject_GetItem(dict, key); + Py_DECREF(key); + if (args == NULL) { + goto onError; + } + if (PyList_Append(fargs, args)) + goto onError; + } + else { + args = PyList_GET_ITEM(fargs, fargidx); + Py_INCREF(args); + fargidx++; + } + args_owned = 1; + arglen = -1; + argidx = -2; + } while (--fmtcnt >= 0) { c = PyUnicode_READ(fmtkind, fmt, fmtpos++); - if (c < '0' || c > '9') - break; - if ((width*10) / 10 != width) { - PyErr_SetString(PyExc_ValueError, - "width too big"); - goto onError; + switch (c) { + case '-': flags |= F_LJUST; continue; + case '+': flags |= F_SIGN; continue; + case ' ': flags |= F_BLANK; continue; + case '#': flags |= F_ALT; continue; + case '0': flags |= F_ZERO; continue; } - width = width*10 + (c - '0'); - } - } - if (c == '.') { - prec = 0; - if (--fmtcnt >= 0) - c = PyUnicode_READ(fmtkind, fmt, fmtpos++); + break; + } if (c == '*') { v = getnextarg(args, arglen, &argidx); if (v == NULL) @@ -13822,307 +13792,337 @@ PyUnicode_Format(PyObject *format, PyObj "* wants int"); goto onError; } - prec = PyLong_AsLong(v); - if (prec == -1 && PyErr_Occurred()) + width = PyLong_AsLong(v); + if (width == -1 && PyErr_Occurred()) goto onError; - if (prec < 0) - prec = 0; + if (width < 0) { + flags |= F_LJUST; + width = -width; + } if (--fmtcnt >= 0) c = PyUnicode_READ(fmtkind, fmt, fmtpos++); } else if (c >= '0' && c <= '9') { - prec = c - '0'; + width = c - '0'; while (--fmtcnt >= 0) { c = PyUnicode_READ(fmtkind, fmt, fmtpos++); if (c < '0' || c > '9') break; - if ((prec*10) / 10 != prec) { + if ((width*10) / 10 != width) { PyErr_SetString(PyExc_ValueError, - "prec too big"); + "width too big"); goto onError; } - prec = prec*10 + (c - '0'); + width = width*10 + (c - '0'); } } - } /* prec */ - if (fmtcnt >= 0) { - if (c == 'h' || c == 'l' || c == 'L') { + if (c == '.') { + prec = 0; if (--fmtcnt >= 0) c = PyUnicode_READ(fmtkind, fmt, fmtpos++); - } - } - if (fmtcnt < 0) { - PyErr_SetString(PyExc_ValueError, - "incomplete format"); - goto onError; - } - if (c != '%') { + if (c == '*') { + v = getnextarg(args, arglen, &argidx); + if (v == NULL) + goto onError; + if (!PyLong_Check(v)) { + PyErr_SetString(PyExc_TypeError, + "* wants int"); + goto onError; + } + prec = PyLong_AsLong(v); + if (prec == -1 && PyErr_Occurred()) + goto onError; + if (prec < 0) + prec = 0; + if (--fmtcnt >= 0) + c = PyUnicode_READ(fmtkind, fmt, fmtpos++); + } + else if (c >= '0' && c <= '9') { + prec = c - '0'; + while (--fmtcnt >= 0) { + c = PyUnicode_READ(fmtkind, fmt, fmtpos++); + if (c < '0' || c > '9') + break; + if ((prec*10) / 10 != prec) { + PyErr_SetString(PyExc_ValueError, + "prec too big"); + goto onError; + } + prec = prec*10 + (c - '0'); + } + } + } /* prec */ + if (fmtcnt >= 0) { + if (c == 'h' || c == 'l' || c == 'L') { + if (--fmtcnt >= 0) + c = PyUnicode_READ(fmtkind, fmt, fmtpos++); + } + } + if (fmtcnt < 0) { + PyErr_SetString(PyExc_ValueError, + "incomplete format"); + goto onError; + } + + if (c == '%') { + if (write) + PyUnicode_WRITE(reskind, resdata, respos, '%'); + respos++; + continue; + } + + + sign = 0; + signchar = ' '; + fill = ' '; v = getnextarg(args, arglen, &argidx); if (v == NULL) goto onError; - } - sign = 0; - fill = ' '; - fillobj = blank; - switch (c) { - - case '%': - _PyAccu_Accumulate(&acc, percent); - continue; - - case 's': - case 'r': - case 'a': - if (PyUnicode_CheckExact(v) && c == 's') { - temp = v; - Py_INCREF(temp); - } - else { - if (c == 's') - temp = PyObject_Str(v); - else if (c == 'r') - temp = PyObject_Repr(v); - else - temp = PyObject_ASCII(v); + + switch (c) { + + case 's': + case 'r': + case 'a': + if (!write) { + if (PyUnicode_CheckExact(v) && c == 's') { + temp = v; + Py_INCREF(temp); + } + else { + if (c == 's') + temp = PyObject_Str(v); + else if (c == 'r') + temp = PyObject_Repr(v); + else + temp = PyObject_ASCII(v); + if (temp == NULL) + goto onError; + if (!PyUnicode_Check(temp)) { + Py_DECREF(temp); + PyErr_SetString(PyExc_TypeError, + "%s argument has non-string str()"); + goto onError; + } + } + } + break; + + case 'i': + case 'd': + case 'u': + case 'o': + case 'x': + case 'X': + if (!write) { + int isnumok = 0; + if (PyNumber_Check(v)) { + PyObject *iobj=NULL; + + if (PyLong_Check(v)) { + iobj = v; + Py_INCREF(iobj); + } + else { + iobj = PyNumber_Long(v); + } + if (iobj!=NULL) { + if (PyLong_Check(iobj)) { + temp = formatlong(iobj, flags, prec, (c == 'i'? 'd': c)); + Py_DECREF(iobj); + isnumok = 1; + } + else { + Py_DECREF(iobj); + } + } + } + if (!isnumok) { + PyErr_Format(PyExc_TypeError, + "%%%c format: a number is required, " + "not %.200s", (char)c, Py_TYPE(v)->tp_name); + goto onError; + } + } + sign = 1; + if (flags & F_ZERO) + fill = '0'; + break; + + case 'e': + case 'E': + case 'f': + case 'F': + case 'g': + case 'G': + sign = 1; + if (flags & F_ZERO) + fill = '0'; + if (!write) + temp = formatfloat(v, flags, prec, c); + break; + + case 'c': + if (!write) { + Py_UCS4 ch = formatchar(v); + if (ch == (Py_UCS4) -1) + goto onError; + temp = _PyUnicode_FromUCS4(&ch, 1); + } + break; + + default: + PyErr_Format(PyExc_ValueError, + "unsupported format character '%c' (0x%x) " + "at index %zd", + (31<=c && c<=126) ? (char)c : '?', + (int)c, + fmtpos - 1); + goto onError; + } + + if (!write) { if (temp == NULL) goto onError; - if (PyUnicode_Check(temp)) - /* nothing to do */; - else { - Py_DECREF(temp); - PyErr_SetString(PyExc_TypeError, - "%s argument has non-string str()"); + if (PyUnicode_READY(temp) == -1) { + Py_CLEAR(temp); goto onError; } - } - if (PyUnicode_READY(temp) == -1) { - Py_CLEAR(temp); - goto onError; - } + if (PyList_Append(fargs, temp)) + goto onError; + } + else { + temp = PyList_GET_ITEM(fargs, fargidx); + Py_INCREF(temp); + fargidx++; + } + pbuf = PyUnicode_DATA(temp); kind = PyUnicode_KIND(temp); len = PyUnicode_GET_LENGTH(temp); - if (prec >= 0 && len > prec) - len = prec; - break; - - case 'i': - case 'd': - case 'u': - case 'o': - case 'x': - case 'X': - isnumok = 0; - if (PyNumber_Check(v)) { - PyObject *iobj=NULL; - - if (PyLong_Check(v)) { - iobj = v; - Py_INCREF(iobj); + if (c == 's' || c == 'r' || c == 'a') { + if (prec >= 0 && len > prec) + len = prec; + } + + /* pbuf is initialized here. */ + pindex = 0; + if (sign) { + Py_UCS4 tempch = PyUnicode_READ(kind, pbuf, pindex); + if (tempch == '-') { + signchar = '-'; + len--; + pindex++; } - else { - iobj = PyNumber_Long(v); + else if (tempch == '+') { + signchar = '+'; + len--; + pindex++; } - if (iobj!=NULL) { - if (PyLong_Check(iobj)) { - isnumok = 1; - temp = formatlong(iobj, flags, prec, (c == 'i'? 'd': c)); - Py_DECREF(iobj); - if (!temp) - goto onError; - if (PyUnicode_READY(temp) == -1) { - Py_CLEAR(temp); - goto onError; - } - pbuf = PyUnicode_DATA(temp); - kind = PyUnicode_KIND(temp); - len = PyUnicode_GET_LENGTH(temp); - sign = 1; - } - else { - Py_DECREF(iobj); - } + else if (flags & F_SIGN) + signchar = '+'; + else if (flags & F_BLANK) + signchar = ' '; + else + sign = 0; + } + if (width < len) + width = len; + if (sign) { + if (fill != ' ') { + if (write) + PyUnicode_WRITE(reskind, resdata, respos, signchar); + respos++; } - } - if (!isnumok) { - PyErr_Format(PyExc_TypeError, - "%%%c format: a number is required, " - "not %.200s", (char)c, Py_TYPE(v)->tp_name); - goto onError; - } - if (flags & F_ZERO) { - fill = '0'; - fillobj = zero; - } - break; - - case 'e': - case 'E': - case 'f': - case 'F': - case 'g': - case 'G': - temp = formatfloat(v, flags, prec, c); - if (!temp) - goto onError; - if (PyUnicode_READY(temp) == -1) { - Py_CLEAR(temp); - goto onError; - } - pbuf = PyUnicode_DATA(temp); - kind = PyUnicode_KIND(temp); - len = PyUnicode_GET_LENGTH(temp); - sign = 1; - if (flags & F_ZERO) { - fill = '0'; - fillobj = zero; - } - break; - - case 'c': - { - Py_UCS4 ch = formatchar(v); - if (ch == (Py_UCS4) -1) - goto onError; - temp = _PyUnicode_FromUCS4(&ch, 1); - if (temp == NULL) - goto onError; - pbuf = PyUnicode_DATA(temp); - kind = PyUnicode_KIND(temp); - len = PyUnicode_GET_LENGTH(temp); - break; - } - - default: - PyErr_Format(PyExc_ValueError, - "unsupported format character '%c' (0x%x) " - "at index %zd", - (31<=c && c<=126) ? (char)c : '?', - (int)c, - fmtpos - 1); - goto onError; - } - /* pbuf is initialized here. */ - pindex = 0; - if (sign) { - if (PyUnicode_READ(kind, pbuf, pindex) == '-') { - signobj = minus; - len--; - pindex++; - } - else if (PyUnicode_READ(kind, pbuf, pindex) == '+') { - signobj = plus; - len--; - pindex++; - } - else if (flags & F_SIGN) - signobj = plus; - else if (flags & F_BLANK) - signobj = blank; - else - sign = 0; - } - if (width < len) - width = len; - if (sign) { - if (fill != ' ') { - assert(signobj != NULL); - if (_PyAccu_Accumulate(&acc, signobj)) - goto onError; - } - if (width > len) - width--; - } - if ((flags & F_ALT) && (c == 'x' || c == 'X' || c == 'o')) { - assert(PyUnicode_READ(kind, pbuf, pindex) == '0'); - assert(PyUnicode_READ(kind, pbuf, pindex + 1) == c); - if (fill != ' ') { - second = get_latin1_char( - PyUnicode_READ(kind, pbuf, pindex + 1)); - pindex += 2; - if (second == NULL || - _PyAccu_Accumulate(&acc, zero) || - _PyAccu_Accumulate(&acc, second)) - goto onError; - Py_CLEAR(second); - } - width -= 2; - if (width < 0) - width = 0; - len -= 2; - } - if (width > len && !(flags & F_LJUST)) { - assert(fillobj != NULL); - if (repeat_accumulate(&acc, fillobj, width - len)) - goto onError; - width = len; - } - if (fill == ' ') { - if (sign) { - assert(signobj != NULL); - if (_PyAccu_Accumulate(&acc, signobj)) - goto onError; + if (width > len) + width--; } if ((flags & F_ALT) && (c == 'x' || c == 'X' || c == 'o')) { assert(PyUnicode_READ(kind, pbuf, pindex) == '0'); - assert(PyUnicode_READ(kind, pbuf, pindex+1) == c); - second = get_latin1_char( - PyUnicode_READ(kind, pbuf, pindex + 1)); - pindex += 2; - if (second == NULL || - _PyAccu_Accumulate(&acc, zero) || - _PyAccu_Accumulate(&acc, second)) - goto onError; - Py_CLEAR(second); - } - } - /* Copy all characters, preserving len */ - if (temp != NULL) { + assert(PyUnicode_READ(kind, pbuf, pindex + 1) == c); + if (fill != ' ') { + if (write) { + PyUnicode_WRITE(reskind, resdata, respos, '0'); + PyUnicode_WRITE(reskind, resdata, respos+1, c); + } + respos += 2; + pindex += 2; + } + width -= 2; + if (width < 0) + width = 0; + len -= 2; + } + if (width > len && !(flags & F_LJUST)) { + if (write) + FILL(reskind, resdata, fill, respos, width - len); + respos += (width - len); + width = len; + } + if (fill == ' ') { + if (sign) { + if (write) + PyUnicode_WRITE(reskind, resdata, respos, signchar); + respos++; + } + if ((flags & F_ALT) && (c == 'x' || c == 'X' || c == 'o')) { + assert(PyUnicode_READ(kind, pbuf, pindex) == '0'); + assert(PyUnicode_READ(kind, pbuf, pindex+1) == c); + if (write) { + PyUnicode_WRITE(reskind, resdata, respos, '0'); + PyUnicode_WRITE(reskind, resdata, respos+1, c); + } + respos += 2; + pindex += 2; + } + } + assert(temp != NULL); assert(pbuf == PyUnicode_DATA(temp)); - v = PyUnicode_Substring(temp, pindex, pindex + len); - } - else { - const char *p = (const char *) pbuf; - assert(pbuf != NULL); - p += kind * pindex; - v = PyUnicode_FromKindAndData(kind, p, len); - } - if (v == NULL) - goto onError; - r = _PyAccu_Accumulate(&acc, v); - Py_DECREF(v); - if (r) - goto onError; - if (width > len && repeat_accumulate(&acc, blank, width - len)) - goto onError; - if (dict && (argidx < arglen) && c != '%') { - PyErr_SetString(PyExc_TypeError, - "not all arguments converted during string formatting"); - goto onError; - } - Py_CLEAR(temp); - } /* '%' */ - } /* until end */ - if (argidx < arglen && !dict) { - PyErr_SetString(PyExc_TypeError, - "not all arguments converted during string formatting"); - goto onError; - } - - result = _PyAccu_Finish(&acc); + if (write) { + copy_characters(result, respos, temp, pindex, len); + } + else { + maxchar2 = _PyUnicode_FindMaxChar(temp, pindex, pindex + len); + maxchar |= maxchar2; + } + respos += len; + + if (width > len) { + if (write) + FILL(reskind, resdata, ' ', respos, width - len); + respos += (width - len); + } + if (dict && (argidx < arglen) && c != '%') { + PyErr_SetString(PyExc_TypeError, + "not all arguments converted during string formatting"); + goto onError; + } + Py_CLEAR(temp); + } /* '%' */ + } /* until end */ + if (argidx < arglen && !dict) { + PyErr_SetString(PyExc_TypeError, + "not all arguments converted during string formatting"); + goto onError; + } + } + if (args_owned) { Py_DECREF(args); } + Py_DECREF(fargs); Py_DECREF(uformat); Py_XDECREF(temp); Py_XDECREF(second); + assert(_PyUnicode_CheckConsistency(result, 1)); return result; onError: Py_DECREF(uformat); Py_XDECREF(temp); Py_XDECREF(second); - _PyAccu_Destroy(&acc); + Py_XDECREF(result); + Py_XDECREF(fargs); if (args_owned) { Py_DECREF(args); }