cpython: 42fbb4f9b540 (original) (raw)
--- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -6986,8 +6986,6 @@ PyUnicode_DecodeASCII(const char *s, v = PyUnicode_New(size, 127); if (v == NULL) goto onError;
- if (size == 0)
kind = PyUnicode_KIND(v); data = PyUnicode_DATA(v); outpos = 0; @@ -13856,20 +13854,22 @@ PyUnicode_Format(PyObject *format, PyObj "incomplete format"); goto onError; }return v;[](#l1.8)
if (c != '%') {[](#l1.16)
v = getnextarg(args, arglen, &argidx);[](#l1.17)
if (v == NULL)[](#l1.18)
goto onError;[](#l1.19)
}[](#l1.20)
if (c == '%') {[](#l1.22)
_PyAccu_Accumulate(&acc, percent);[](#l1.23)
continue;[](#l1.24)
}[](#l1.25)
v = getnextarg(args, arglen, &argidx);[](#l1.28)
if (v == NULL)[](#l1.29)
goto onError;[](#l1.30)
+ sign = 0; fill = ' '; fillobj = blank; switch (c) {
case '%':[](#l1.37)
_PyAccu_Accumulate(&acc, percent);[](#l1.38)
continue;[](#l1.39)
- case 's': case 'r': case 'a': @@ -13884,26 +13884,7 @@ PyUnicode_Format(PyObject *format, PyObj temp = PyObject_Repr(v); else temp = PyObject_ASCII(v);
if (temp == NULL)[](#l1.48)
goto onError;[](#l1.49)
if (PyUnicode_Check(temp))[](#l1.50)
/* nothing to do */;[](#l1.51)
else {[](#l1.52)
Py_DECREF(temp);[](#l1.53)
PyErr_SetString(PyExc_TypeError,[](#l1.54)
"%s argument has non-string str()");[](#l1.55)
goto onError;[](#l1.56)
}[](#l1.57)
}[](#l1.58)
if (PyUnicode_READY(temp) == -1) {[](#l1.59)
Py_CLEAR(temp);[](#l1.60)
goto onError;[](#l1.61)
}[](#l1.62)
pbuf = PyUnicode_DATA(temp);[](#l1.63)
kind = PyUnicode_KIND(temp);[](#l1.64)
len = PyUnicode_GET_LENGTH(temp);[](#l1.65)
if (prec >= 0 && len > prec)[](#l1.66)
len = prec;[](#l1.67)
}[](#l1.68) break;[](#l1.69)
case 'i': @@ -13926,18 +13907,9 @@ PyUnicode_Format(PyObject *format, PyObj if (iobj!=NULL) { if (PyLong_Check(iobj)) { isnumok = 1;
sign = 1;[](#l1.76) temp = formatlong(iobj, flags, prec, (c == 'i'? 'd': c));[](#l1.77) Py_DECREF(iobj);[](#l1.78)
if (!temp)[](#l1.79)
goto onError;[](#l1.80)
if (PyUnicode_READY(temp) == -1) {[](#l1.81)
Py_CLEAR(temp);[](#l1.82)
goto onError;[](#l1.83)
}[](#l1.84)
pbuf = PyUnicode_DATA(temp);[](#l1.85)
kind = PyUnicode_KIND(temp);[](#l1.86)
len = PyUnicode_GET_LENGTH(temp);[](#l1.87)
sign = 1;[](#l1.88) }[](#l1.89) else {[](#l1.90) Py_DECREF(iobj);[](#l1.91)
@@ -13962,21 +13934,12 @@ PyUnicode_Format(PyObject *format, PyObj case 'F': case 'g': case 'G':
temp = formatfloat(v, flags, prec, c);[](#l1.96)
if (!temp)[](#l1.97)
goto onError;[](#l1.98)
if (PyUnicode_READY(temp) == -1) {[](#l1.99)
Py_CLEAR(temp);[](#l1.100)
goto onError;[](#l1.101)
}[](#l1.102)
pbuf = PyUnicode_DATA(temp);[](#l1.103)
kind = PyUnicode_KIND(temp);[](#l1.104)
len = PyUnicode_GET_LENGTH(temp);[](#l1.105) sign = 1;[](#l1.106) if (flags & F_ZERO) {[](#l1.107) fill = '0';[](#l1.108) fillobj = zero;[](#l1.109) }[](#l1.110)
temp = formatfloat(v, flags, prec, c);[](#l1.111) break;[](#l1.112)
case 'c': @@ -13985,11 +13948,6 @@ PyUnicode_Format(PyObject *format, PyObj if (ch == (Py_UCS4) -1) goto onError; temp = _PyUnicode_FromUCS4(&ch, 1);
if (temp == NULL)[](#l1.119)
goto onError;[](#l1.120)
pbuf = PyUnicode_DATA(temp);[](#l1.121)
kind = PyUnicode_KIND(temp);[](#l1.122)
len = PyUnicode_GET_LENGTH(temp);[](#l1.123) break;[](#l1.124) }[](#l1.125)
@@ -14002,6 +13960,22 @@ PyUnicode_Format(PyObject *format, PyObj fmtpos - 1); goto onError; }
if (temp == NULL)[](#l1.131)
goto onError;[](#l1.132)
assert (PyUnicode_Check(temp));[](#l1.133)
if (PyUnicode_READY(temp) == -1) {[](#l1.134)
Py_CLEAR(temp);[](#l1.135)
goto onError;[](#l1.136)
}[](#l1.137)
kind = PyUnicode_KIND(temp);[](#l1.138)
pbuf = PyUnicode_DATA(temp);[](#l1.139)
len = PyUnicode_GET_LENGTH(temp);[](#l1.140)
if (c == 's' || c == 'r' || c == 'a') {[](#l1.142)
if (prec >= 0 && len > prec)[](#l1.143)
len = prec;[](#l1.144)
}[](#l1.145)