mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Merged revisions 71627 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r71627 | benjamin.peterson | 2009-04-15 16:26:36 -0500 (Wed, 15 Apr 2009) | 4 lines call __float__ on str subclasses #5759 tests by R. David Murray ........
This commit is contained in:
parent
50a1469557
commit
2808d3c418
3 changed files with 12 additions and 1 deletions
|
@ -1533,7 +1533,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 (PyUnicode_Check(x))
|
||||
/* If it's a string, but not a string subclass, use
|
||||
PyFloat_FromString. */
|
||||
if (PyUnicode_CheckExact(x))
|
||||
return PyFloat_FromString(x);
|
||||
return PyNumber_Float(x);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue