mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
Make subclasses of int, long, complex, float, and unicode perform type
conversion using the proper magic slot (e.g., __int__()). Also move conversion code out of PyNumber_*() functions in the C API into the nb_* function. Applied patch #1109424. Thanks Walter Doewald.
This commit is contained in:
parent
d7c795e729
commit
c3647ac93e
10 changed files with 326 additions and 76 deletions
|
@ -926,7 +926,10 @@ float_int(PyObject *v)
|
|||
static PyObject *
|
||||
float_float(PyObject *v)
|
||||
{
|
||||
Py_INCREF(v);
|
||||
if (PyFloat_CheckExact(v))
|
||||
Py_INCREF(v);
|
||||
else
|
||||
v = PyFloat_FromDouble(((PyFloatObject *)v)->ob_fval);
|
||||
return v;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue