summaryrefslogtreecommitdiff
path: root/Objects/floatobject.c
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2012-03-17 16:58:12 +0100
committerGeorg Brandl <georg@python.org>2012-03-17 16:58:12 +0100
commitffd4830f6ab0942a463772a01a91f051bfa2d376 (patch)
tree14d5f982ed3d51197f0dd69370d3f6002aec8e1e /Objects/floatobject.c
parent206a0cc1b0f2545eef212be6210b4bf7008815ba (diff)
parent5d6d9423be73e8c6f3f18fa3e006573fc5836236 (diff)
downloadcpython-ffd4830f6ab0942a463772a01a91f051bfa2d376.tar.gz
merge with 3.2
Diffstat (limited to 'Objects/floatobject.c')
-rw-r--r--Objects/floatobject.c32
1 files changed, 7 insertions, 25 deletions
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
index e146a4fc7c..a738249790 100644
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -15,11 +15,6 @@
#define MIN(x, y) ((x) < (y) ? (x) : (y))
-#ifdef _OSF_SOURCE
-/* OSF1 5.1 doesn't make this available with XOPEN_SOURCE_EXTENDED defined */
-extern int finite(double);
-#endif
-
/* Special free list
Since some Python programs can spend much of their time allocating
@@ -179,25 +174,14 @@ PyFloat_FromString(PyObject *v)
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;
}
- last = s + len;
}
else if (PyObject_AsCharBuffer(v, &s, &len)) {
PyErr_SetString(PyExc_TypeError,
@@ -523,8 +507,7 @@ float_richcompare(PyObject *v, PyObject *w, int op)
return PyBool_FromLong(r);
Unimplemented:
- Py_INCREF(Py_NotImplemented);
- return Py_NotImplemented;
+ Py_RETURN_NOTIMPLEMENTED;
}
static Py_hash_t
@@ -1080,7 +1063,7 @@ static char
char_from_hex(int x)
{
assert(0 <= x && x < 16);
- return "0123456789abcdef"[x];
+ return Py_hexdigits[x];
}
static int
@@ -1753,9 +1736,8 @@ float__format__(PyObject *self, PyObject *args)
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,
@@ -2251,7 +2233,7 @@ _PyFloat_Pack8(double x, unsigned char *p, int le)
/* Eighth byte */
*p = flo & 0xFF;
- p += incr;
+ /* p += incr; */
/* Done */
return 0;