Mercurial > cpython-lru_cache-weakref
diff Objects/floatobject.c @ 72475:8beaa9a37387
Implement PEP 393.
| author | Martin v. Löwis <martin@v.loewis.de> |
|---|---|
| date | Wed, 28 Sep 2011 07:41:54 +0200 |
| parents | d0b0fcbb40db |
| children | d76338eacf7c |
line wrap: on
line diff
--- a/Objects/floatobject.c Tue Sep 27 20:52:04 2011 -0500 +++ b/Objects/floatobject.c Wed Sep 28 07:41:54 2011 +0200 @@ -174,20 +174,10 @@ PyObject *result = NULL; if (PyUnicode_Check(v)) { - Py_ssize_t i, buflen = PyUnicode_GET_SIZE(v); - Py_UNICODE *bufptr; - s_buffer = PyUnicode_TransformDecimalToASCII( - PyUnicode_AS_UNICODE(v), buflen); + s_buffer = _PyUnicode_TransformDecimalAndSpaceToASCII(v); if (s_buffer == NULL) return NULL; - /* Replace non-ASCII whitespace with ' ' */ - bufptr = PyUnicode_AS_UNICODE(s_buffer); - for (i = 0; i < buflen; i++) { - Py_UNICODE ch = bufptr[i]; - if (ch > 127 && Py_UNICODE_ISSPACE(ch)) - bufptr[i] = ' '; - } - s = _PyUnicode_AsStringAndSize(s_buffer, &len); + s = PyUnicode_AsUTF8AndSize(s_buffer, &len); if (s == NULL) { Py_DECREF(s_buffer); return NULL; @@ -1741,9 +1731,8 @@ if (!PyArg_ParseTuple(args, "U:__format__", &format_spec)) return NULL; - return _PyFloat_FormatAdvanced(self, - PyUnicode_AS_UNICODE(format_spec), - PyUnicode_GET_SIZE(format_spec)); + return _PyFloat_FormatAdvanced(self, format_spec, 0, + PyUnicode_GET_LENGTH(format_spec)); } PyDoc_STRVAR(float__format__doc,
