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:
Brett Cannon 2005-04-26 03:45:26 +00:00
parent d7c795e729
commit c3647ac93e
10 changed files with 326 additions and 76 deletions

View file

@ -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;
}