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

@ -826,7 +826,10 @@ int_coerce(PyObject **pv, PyObject **pw)
static PyObject *
int_int(PyIntObject *v)
{
Py_INCREF(v);
if (PyInt_CheckExact(v))
Py_INCREF(v);
else
v = (PyIntObject *)PyInt_FromLong(v->ob_ival);
return (PyObject *)v;
}