summaryrefslogtreecommitdiffstats
path: root/Objects/floatobject.c
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-04-15 21:26:36 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-04-15 21:26:36 (GMT)
commit99d36f15639b9efa9ad110005605ae28ca65e829 (patch)
treefd2a8fa4f81dd7fba0641f708c594b6e962a3100 /Objects/floatobject.c
parent5c9914899bb220eefceb4fad685694bbc04a905c (diff)
downloadcpython-99d36f15639b9efa9ad110005605ae28ca65e829.zip
cpython-99d36f15639b9efa9ad110005605ae28ca65e829.tar.gz
cpython-99d36f15639b9efa9ad110005605ae28ca65e829.tar.bz2
call __float__ on str subclasses #5759
tests by R. David Murray
Diffstat (limited to 'Objects/floatobject.c')
-rw-r--r--Objects/floatobject.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
index 881671c..4f041f4 100644
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -1630,7 +1630,9 @@ float_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
return float_subtype_new(type, args, kwds); /* Wimp out */
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:float", kwlist, &x))
return NULL;
- if (PyString_Check(x))
+ /* If it's a string, but not a string subclass, use
+ PyFloat_FromString. */
+ if (PyString_CheckExact(x))
return PyFloat_FromString(x, NULL);
return PyNumber_Float(x);
}